public async Task <CompanyCreateModel> UpdateCompany(CompanyCreateModel data) { try { CompanyCreateModel model = null; switch (data.companyType) { case "MSP": tblMSPDetail dataMSP = await Task.Run(() => ManageMSP.UpdateMSP(data.ConvertTotblMSPDetail())); model = dataMSP.ConvertTocompany(); break; case "Customer": tblCustomer dataCustomer = await Task.Run(() => ManageCustomer.UpdateCustomer(data.ConvertTotblCustomer())); model = dataCustomer.ConvertTocompany(); break; case "Supplier": tblSupplier dataSupplier = await Task.Run(() => ManageSupplier.UpdateSupplier(data.ConvertTotblSupplier())); model = dataSupplier.ConvertTocompany(); break; } return(model); } catch (Exception) { throw; } }
internal static async Task DeleteMSP(long Id) { try { using (db = new eMSPEntities()) { tblMSPDetail obj = await db.tblMSPDetails.FindAsync(Id); db.tblMSPDetails.Remove(obj); int x = await Task.Run(() => db.SaveChangesAsync()); } } catch (Exception) { throw; } }
internal static async Task <tblMSPDetail> UpdateMSP(tblMSPDetail model) { try { using (db = new eMSPEntities()) { db.Entry(model).State = EntityState.Modified; int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception) { throw; } }
internal static async Task <tblMSPDetail> InsertMSP(tblMSPDetail model) { try { using (db = new eMSPEntities()) { model = db.tblMSPDetails.Add(model); int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception) { throw; } }
public static CompanyCreateModel ConvertTocompany(this tblMSPDetail data) { return(new CompanyCreateModel() { id = Convert.ToString(data.ID), companyName = data.CompanyName, companyEmail = data.EmailAddress, companyPhoneNumber = data.PhoneNumber, companyAddress = data.Address, companyCity = data.City, companyWebsite = data.WebSite, CountryID = data.CountryID.ToString(), companyCountry = data.tblCountry != null ? data.tblCountry.Name : "", StateID = data.StateID.ToString(), companyState = data.tblCountryState != null ? data.tblCountryState.Name : "", companyType = "MSP", createdUserID = data.CreatedUserID, updatedUserID = data.UpdatedUserID, createdTimestamp = data.CreatedTimestamp, updatedTimestamp = data.UpdatedTimestamp.Value, LogoPath = data.LogoPath }); }
public async Task <CompanyCreateModel> GetCompany(CompanyModel data) { try { CompanyCreateModel model = null; long Id = data != null?Convert.ToInt64(data.id) : 0; switch (data.companyType) { case "MSP": long id = Convert.ToInt64(ConfigurationManager.AppSettings["MSP_ID"]); Id = id != null ? id : Id; tblMSPDetail dataMSP = await Task.Run(() => ManageMSP.GetMSPDetails(Id)); model = dataMSP.ConvertTocompany(); break; case "Customer": tblCustomer dataCustomer = await Task.Run(() => ManageCustomer.GetCustomerDetails(Id)); model = dataCustomer.ConvertTocompany(); break; case "Supplier": tblSupplier dataSupplier = await Task.Run(() => ManageSupplier.GetSupplierDetails(Id)); model = dataSupplier.ConvertTocompany(); break; } return(model); } catch (Exception) { throw; } }