public int DeleteInvoice(int InvoiceId) { IMSDB.tblInvoiceDetails.RemoveRange(IMSDB.tblInvoiceDetails.Where(p => p.InvoiceId == InvoiceId)); IMSDB.tblInvoices.Remove(IMSDB.tblInvoices.Where(p => p.InvoiceId == InvoiceId).FirstOrDefault()); IMSDB.SaveChanges(); return(1); }
public EmployeeDTO SaveUpdatedEmployee(EmployeeDTO dto) { var emp = IMSDB.Employees.Find(dto.BasicInfo.BadgeNumber); if (!UserAddData?.IMSEmployeesBusinessUnitsEditRights?.Contains(emp.BusinessUnitID) ?? false) { throw new Exception("You have no rights to edit employees of this business unit"); } emp.FromDTO(dto, UserAddData?.IMSEmployeeSectionEditRights); var results = new List <ValidationResult>(); var context = new ValidationContext(emp); if (!Validator.TryValidateObject(emp, context, results, true)) { throw new Exception(string.Join(", ", results.Select(er => er.ErrorMessage))); } IMSDB.SaveChanges(); IMSDB.Entry(emp).Reload(); dto.FromEF(emp, User.IsInRole(AppRole.HREmployeesCreatorRole) ? null : UserAddData?.IMSEmployeeSectionViewRights); return(dto); }
public int DeleteCompany(int CompanyId) { IMSDB.tblCompanyLicenseDetails.RemoveRange(IMSDB.tblCompanyLicenseDetails.Where(p => p.CompanyId == CompanyId)); IMSDB.tblCompanies.Remove(IMSDB.tblCompanies.Where(p => p.CompanyId == CompanyId).FirstOrDefault()); IMSDB.SaveChanges(); return(1); }
public EmployeeDTO SaveNewEmployee(EmployeeDTO dto) { if (!UserAddData?.IMSEmployeesBusinessUnitsEditRights?.Contains(dto.BasicCompanyInfo?.BusinessUnitID) ?? false) { throw new Exception("You have no rights to edit employees of this business unit"); } var emp = IMSDB.Employees.Add(new DataModels.Models.IMS.Employee()); emp.FromDTO(dto, UserAddData?.IMSEmployeeSectionEditRights); var results = new List <ValidationResult>(); var context = new ValidationContext(emp); if (!Validator.TryValidateObject(emp, context, results, true)) { throw new Exception(string.Join(", ", results.Select(er => er.ErrorMessage))); } IMSDB.SaveChanges(); if (dto.BasicInfo.PhotoBase64 != null) { App.PhotoRepository.SaveEmployeePhotoFromBase64(dto.BasicInfo.BadgeNumber, dto.BasicInfo.PhotoBase64); } else { App.PhotoRepository.DeleteEmployeePhotoIfExists(dto.BasicInfo.BadgeNumber); } IMSDB.Entry(emp).Reload(); dto.FromEF(emp); return(dto); }
public int DeleteItem(int ItemId) { IMSDB.tblItemDetails.RemoveRange(IMSDB.tblItemDetails.Where(p => p.ItemId == ItemId)); IMSDB.tblItems.Remove(IMSDB.tblItems.Where(p => p.ItemId == ItemId).FirstOrDefault()); IMSDB.SaveChanges(); return(1); }
public AccountingMethodVM EditAccountingMethod(AccountingMethodVM c) { DB.tblAccountingMethod AccountingMethod = IMSDB.tblAccountingMethods.Find(c.AccountingMethodId); if (AccountingMethod != null) { AccountingMethod.AccountingMethod = c.AccountingMethod; AccountingMethod.IsActive = c.IsActive; IMSDB.Entry(AccountingMethod).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public AccountingMethodVM AddAccountingMethod(AccountingMethodVM c) { DB.tblAccountingMethod AccountingMethod = IMSDB.tblAccountingMethods.Add( new DB.tblAccountingMethod { AccountingMethod = c.AccountingMethod, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.AccountingMethodId = AccountingMethod.AccountingMethodId; return(c); }
public ItemUnitVM AddItemUnit(ItemUnitVM c) { DB.tblItemUnit ItemUnit = IMSDB.tblItemUnits.Add( new DB.tblItemUnit { ItemUnit = c.ItemUnit, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.ItemUnitId = ItemUnit.ItemUnitId; return(c); }
public InvoiceTypeVM EditInvoiceType(InvoiceTypeVM c) { DB.tblInvoiceType InvoiceType = IMSDB.tblInvoiceTypes.Find(c.InvoiceTypeId); if (InvoiceType != null) { InvoiceType.InvoiceType = c.InvoiceType; InvoiceType.IsActive = c.IsActive; IMSDB.Entry(InvoiceType).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public InvoiceTypeVM AddInvoiceType(InvoiceTypeVM c) { DB.tblInvoiceType InvoiceType = IMSDB.tblInvoiceTypes.Add( new DB.tblInvoiceType { InvoiceType = c.InvoiceType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.InvoiceTypeId = InvoiceType.InvoiceTypeId; return(c); }
public SupplierTypeVM AddSupplierType(SupplierTypeVM c) { DB.tblSupplierType SupplierType = IMSDB.tblSupplierTypes.Add( new DB.tblSupplierType { SupplierType = c.SupplierType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.SupplierTypeId = SupplierType.SupplierTypeId; return(c); }
public CompanyTypeVM AddCompanyType(CompanyTypeVM c) { DB.tblCompanyType CompanyType = IMSDB.tblCompanyTypes.Add( new DB.tblCompanyType { CompanyType = c.CompanyType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.CompanyTypeId = CompanyType.CompanyTypeId; return(c); }
public CompanyTypeVM EditCompanyType(CompanyTypeVM c) { DB.tblCompanyType CompanyType = IMSDB.tblCompanyTypes.Find(c.CompanyTypeId); if (CompanyType != null) { CompanyType.CompanyType = c.CompanyType; CompanyType.IsActive = c.IsActive; IMSDB.Entry(CompanyType).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public InvoiceStatusVM EditInvoiceStatus(InvoiceStatusVM c) { DB.tblInvoiceStatuses InvoiceStatus = IMSDB.tblInvoiceStatuses.Find(c.InvoiceStatusId); if (InvoiceStatus != null) { InvoiceStatus.InvoiceStatus = c.InvoiceStatus; InvoiceStatus.IsActive = c.IsActive; IMSDB.Entry(InvoiceStatus).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public InvoiceStatusVM AddInvoiceStatus(InvoiceStatusVM c) { DB.tblInvoiceStatuses InvoiceStatus = IMSDB.tblInvoiceStatuses.Add( new DB.tblInvoiceStatuses { InvoiceStatus = c.InvoiceStatus, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.InvoiceStatusId = InvoiceStatus.InvoiceStatusId; return(c); }
public SupplierTypeVM EditSupplierType(SupplierTypeVM c) { DB.tblSupplierType SupplierType = IMSDB.tblSupplierTypes.Find(c.SupplierTypeId); if (SupplierType != null) { SupplierType.SupplierType = c.SupplierType; SupplierType.IsActive = c.IsActive; IMSDB.Entry(SupplierType).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public InvoiceTermVM AddInvoiceTerm(InvoiceTermVM c) { DB.tblInvoiceTerm InvoiceTerm = IMSDB.tblInvoiceTerms.Add( new DB.tblInvoiceTerm { InvoiceTerm = c.InvoiceTerm, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.InvoiceTermId = InvoiceTerm.InvoiceTermId; return(c); }
public ItemTypeVM AddItemType(ItemTypeVM c) { DB.tblItemType ItemType = IMSDB.tblItemTypes.Add( new DB.tblItemType { ItemType = c.ItemType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.ItemTypeId = ItemType.ItemTypeId; return(c); }
public InvoiceTermVM EditInvoiceTerm(InvoiceTermVM c) { DB.tblInvoiceTerm InvoiceTerm = IMSDB.tblInvoiceTerms.Find(c.InvoiceTermId); if (InvoiceTerm != null) { InvoiceTerm.InvoiceTerm = c.InvoiceTerm; InvoiceTerm.IsActive = c.IsActive; IMSDB.Entry(InvoiceTerm).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public ItemUnitVM EditItemUnit(ItemUnitVM c) { DB.tblItemUnit ItemUnit = IMSDB.tblItemUnits.Find(c.ItemUnitId); if (ItemUnit != null) { ItemUnit.ItemUnit = c.ItemUnit; ItemUnit.IsActive = c.IsActive; IMSDB.Entry(ItemUnit).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public CustomerTypeVM AddCustomerType(CustomerTypeVM c) { DB.tblCustomerType CustomerType = IMSDB.tblCustomerTypes.Add( new DB.tblCustomerType { CustomerType = c.CustomerType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.CustomerTypeId = CustomerType.CustomerTypeId; return(c); }
public GSTRegistrationTypeVM EditGSTRegistrationType(GSTRegistrationTypeVM c) { DB.tblGSTRegistrationType GSTRegistrationType = IMSDB.tblGSTRegistrationTypes.Find(c.GSTRegistrationTypeId); if (GSTRegistrationType != null) { GSTRegistrationType.GSTRegistrationType = c.GSTRegistrationType; GSTRegistrationType.IsActive = c.IsActive; IMSDB.Entry(GSTRegistrationType).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public GSTRegistrationTypeVM AddGSTRegistrationType(GSTRegistrationTypeVM c) { DB.tblGSTRegistrationType GSTRegistrationType = IMSDB.tblGSTRegistrationTypes.Add( new DB.tblGSTRegistrationType { GSTRegistrationType = c.GSTRegistrationType, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.GSTRegistrationTypeId = GSTRegistrationType.GSTRegistrationTypeId; return(c); }
public TaxSlabVM EditTaxSlab(TaxSlabVM c) { DB.tblTaxSlab TaxSlab = IMSDB.tblTaxSlabs.Find(c.TaxSlabId); if (TaxSlab != null) { TaxSlab.TaxSlab = c.TaxSlab; TaxSlab.IsActive = c.IsActive; IMSDB.Entry(TaxSlab).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public TaxSlabVM AddTaxSlab(TaxSlabVM c) { DB.tblTaxSlab TaxSlab = IMSDB.tblTaxSlabs.Add( new DB.tblTaxSlab { TaxSlab = c.TaxSlab, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.TaxSlabId = TaxSlab.TaxSlabId; return(c); }
public CountryVM AddCountry(CountryVM c) { DB.tblCountry country = IMSDB.tblCountries.Add( new DB.tblCountry { CountryCode = c.CountryCode, CountryName = c.CountryName, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.CountryId = country.CountryId; return(c); }
public CountryVM EditCountry(CountryVM c) { DB.tblCountry country = IMSDB.tblCountries.Find(c.CountryId); if (country != null) { country.CountryName = c.CountryName; country.CountryCode = c.CountryCode; country.IsActive = c.IsActive; IMSDB.Entry(country).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public HSNSACVM EditHSNSAC(HSNSACVM c) { DB.tblHSNSAC HSNSAC = IMSDB.tblHSNSACs.Find(c.HSNSACId); if (HSNSAC != null) { HSNSAC.TaxRate = c.TaxRate; HSNSAC.HSNSACNo = c.HSNSACNo; HSNSAC.IsActive = c.IsActive; IMSDB.Entry(HSNSAC).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public HSNSACVM AddHSNSAC(HSNSACVM c) { DB.tblHSNSAC HSNSAC = IMSDB.tblHSNSACs.Add( new DB.tblHSNSAC { HSNSACNo = c.HSNSACNo, TaxRate = c.TaxRate, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.HSNSACId = HSNSAC.HSNSACId; return(c); }
public ManufacturerVM EditManufacturer(ManufacturerVM c) { DB.tblManufacturer Manufacturer = IMSDB.tblManufacturers.Find(c.ManufacturerId); if (Manufacturer != null) { Manufacturer.ManufacturerName = c.ManufacturerName; Manufacturer.Description = c.Description; Manufacturer.ShortName = c.ShortName; Manufacturer.IsActive = c.IsActive; IMSDB.Entry(Manufacturer).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }