/// <summary> /// returns company details using its id /// </summary> /// <param name="id"></param> /// <returns></returns> public CompanyVM GetById(object id) { CompanyVM result = new CompanyVM(); try { using (var context = new CMS_DbEntities()) { Tbl_Company company = context.UserSP_CompanyById((int)id).FirstOrDefault(); converter.ConvertToModel(company, result); } } catch (Exception ex) { throw; } return(result); }
/// <summary> /// Update existing Company details /// </summary> /// <param name="companyVm"></param> /// <returns></returns> public int Update(CompanyVM companyVm) { int result = 0; try { using (var context = new CMS_DbEntities()) { Tbl_Company company = context.UserSP_CompanyById(companyVm.ID).FirstOrDefault(); converter.ConvertToEntity(companyVm, company); //will execute UserSP_UpdateCompany context.SaveChanges(); } } catch (Exception ex) { throw; } return(result); }
/// <summary> /// ///delete for end user but changing Delete column /// </summary> /// <param name="id"></param> /// <returns></returns> public int Delete(object id) { int result = 0; try { using (var context = new CMS_DbEntities()) { //Get company using SP UserSP_CompanyById Tbl_Company company = context.UserSP_CompanyById((int)id).FirstOrDefault(); // my storeprocedure change delete status in database for Delete context.Tbl_Company.Remove(company); //will execute sp_DeleteStudentInfo context.SaveChanges(); } } catch (Exception ex) { throw; } return(result); }