Basit Nisar

Basit Nisar

  • 1.7k
  • 84
  • 11k

c# web api error

Sep 9 2023 5:14 PM

i am trying to get the response in my get api but i am facing the error here below is the code:

ReleaseNoteViewModel Releasenote = new ReleaseNoteViewModel()
try
{
    Releasenote.ReleaseVersionTypeView = db.ReleaseVersions.AsNoTracking().Where(x => x.ReleaseVersionID == ID).OrderBy(x => x.ReleaseVersionName).Select(x => new ReleaseVersionModel
        {
            ReleaseVersionID = x.ReleaseVersionID,
                ReleaseVersionName = x.ReleaseVersionName,
                IsCurrentVersion = x.IsCurrentVersion,
                Staff = new ReleaseItemModel
            {
                Improvement = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 2).OrderBy(a => a.ReleaseNoteDescription).Select(a => new ReleaseNotesModel
                        {
                            ReleaseNoteDescription = a.ReleaseNoteDescription
                        }).ToList(),
                    Feature = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 1).Select(a => new ReleaseNotesModel
                        {
                            ReleaseNoteDescription = a.ReleaseNoteDescription
                        }).ToList(),
            },
            ////Adjuster = new ReleaseItemModel
            ////{
            ////    Improvement = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 2).Select(a => new ReleaseNotesModel
            ////    {
            ////        ReleaseNoteDescription = a.ReleaseNoteDescription
            ////    }).ToList(),
            ////    Feature = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 1).Select(a => new ReleaseNotesModel
            ////    {
            ////        ReleaseNoteDescription = a.ReleaseNoteDescription
            ////    }).ToList(),
            ////},
            ////CLient = new ReleaseItemModel
            ////{
            ////    Improvement = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 2).Select(a => new ReleaseNotesModel
            ////    {
            ////        ReleaseNoteDescription = a.ReleaseNoteDescription
            ////    }
            ////          ).ToList(),
            ////    Feature = db.ReleaseNotes.Where(a => a.ReleaseVersionID == x.ReleaseVersionID && a.ReleaseItemTypeID == 1).Select(a => new ReleaseNotesModel
            ////    {
            ////        ReleaseNoteDescription = a.ReleaseNoteDescription
            ////    }).ToList(),
            ////}
        }).ToList < ReleaseItemModel > ();
    return Ok(Releasenote);
} catch (Exception ex)
{
    Global.InsertException(ex);
}
}

// Models returned by AccountController actions. 
public class ReleaseNotesModel {
    public int ReleaseNoteID {
        get;
        set;
    }
    public string ReleaseNoteDescription {
        get;
        set;
    }
    public int ? CreatedBy {
        get;
        set;
    }
    public DateTime ? CreatedDate {
        get;
        set;
    }
    public int ? ModifiedBy {
        get;
        set;
    }
    public DateTime ? ModifiedDate {
        get;
        set;
    }
    public int ? ReleaseVersionID {
        get;
        set;
    }
    public int ? ReleaseItemTypeID {
        get;
        set;
    }
    public int ? UserTypeID {
        get;
        set;
    }
}
public class ReleaseItemModel {
    public int ReleaseItemTypeID {
        get;
        set;
    }
    public string ReleaseItemTypeNote {
        get;
        set;
    }
    public int ? CreatedBy {
        get;
        set;
    }
    public DateTime ? CreatedDate {
        get;
        set;
    }
    public int ? ModifiedBy {
        get;
        set;
    }
    public DateTime ? ModifiedDate {
        get;
        set;
    }
    public List < ReleaseNotesModel > ReleaseNoteTypeView {
        get;
        set;
    }
}
public class UserTypeModel {
    public int UserTypeID {
        get;
        set;
    }
    public string UserTypeName {
        get;
        set;
    }
    public int ? CreatedBy {
        get;
        set;
    }
    public DateTime ? CreatedDate {
        get;
        set;
    }
    public int ? ModifiedBy {
        get;
        set;
    }
    public DateTime ? ModifiedDate {
        get;
        set;
    }
    public List < ReleaseItemModel > ReleaseItemTypeView {
        get;
        set;
    }
}
public class ReleaseVersionModel {
    public int ReleaseVersionID {
        get;
        set;
    }
    public string ReleaseVersionName {
        get;
        set;
    }
    public bool IsCurrentVersion {
        get;
        set;
    }
    public int ? CreatedBy {
        get;
        set;
    }
    public DateTime ? CreatedDate {
        get;
        set;
    }
    public int ? ModifiedBy {
        get;
        set;
    }
    public DateTime ? ModifiedDate {
        get;
        set;
    }
    public List < UserTypeModel > ReleaseUserTypeView {
        get;
        set;
    }
}

i am getting the error

Error CS0029 Cannot implicitly convert type 'WebApplication1.Models.ReleaseItemModel' to 'System.Collections.Generic.List<WebApplication1.Models.UserTypeModel>'


Answers (4)