public Task <SocietyAsset> Create(SocietyAsset societyAsset) { var taskResult = Task.Run(() => { using (var context = new DbContext()) { if (societyAsset.Facility != null) { societyAsset.FacilityId = societyAsset.Facility.Id; societyAsset.Facility = null; } if (societyAsset.Society != null) { societyAsset.SocietyId = societyAsset.Society.Id; societyAsset.Society = null; } if (societyAsset.Floor != null) { societyAsset.FloorId = societyAsset.Floor.Id; societyAsset.Floor = null; } if (societyAsset.Complex != null) { societyAsset.ComplexId = societyAsset.Complex.Id; societyAsset.Complex = null; } context.SocietyAssets.Add(societyAsset); context.SaveChanges(); return(societyAsset); } }); return(taskResult); }
public Task Update(SocietyAsset societyAsset) { var taskResult = Task.Run(() => { using (var context = new DbContext()) { var existingRecord = context.SocietyAssets.FirstOrDefault(p => p.Id == societyAsset.Id); if (existingRecord == null) { throw new Exception("Society Asset detail not found"); } if (societyAsset.Facility != null) { societyAsset.FacilityId = societyAsset.Facility.Id; societyAsset.Facility = null; } if (societyAsset.Society != null) { societyAsset.SocietyId = societyAsset.Society.Id; societyAsset.Society = null; } if (societyAsset.Floor != null) { societyAsset.FloorId = societyAsset.Floor.Id; societyAsset.Floor = null; } if (societyAsset.Complex != null) { societyAsset.ComplexId = societyAsset.Complex.Id; societyAsset.Complex = null; } existingRecord.Name = societyAsset.Name; existingRecord.IsUsable = societyAsset.IsUsable; existingRecord.IsOperational = societyAsset.IsOperational; existingRecord.Quantity = societyAsset.Quantity; existingRecord.CompanyName = societyAsset.CompanyName; existingRecord.Brand = societyAsset.Brand; existingRecord.PurchaseDate = societyAsset.PurchaseDate; existingRecord.ModelNo = societyAsset.ModelNo; existingRecord.SrNo = societyAsset.SrNo; existingRecord.ContactPerson = societyAsset.ContactPerson; existingRecord.CustomerCareNo = societyAsset.CustomerCareNo; context.SaveChanges(); } }); return(taskResult); }
public Task Update(SocietyAsset societyAsset) { return(_societyAssetRepository.Update(societyAsset)); }
public Task <SocietyAsset> Create(SocietyAsset societyAsset) { return(_societyAssetRepository.Create(societyAsset)); }