public Phone Delete(Guid id) { var phone = _repository.GetOne(id); _repository.Delete(phone); if (Commit()) { return(phone); } return(null); }
public IActionResult DeleteConfirmed(int id) { var phone = _phoneRepository.GetById(id); _phoneRepository.Delete(phone); return(RedirectToAction(nameof(Index))); }
public async Task <IHttpActionResult> DeletePhoneNumber(int id) { int idClient = User.Identity.GetUserId <int>(); var client = await Manager.FindUserByIdWithPhoneNumberAsync(idClient); var phoneNumber = _repoPhone.GetUniq(x => x.Id == id); int countSecondary = client.SecondaryPhone.Where(x => x.Id == id).Count(); if ((client.PrincipalPhone != null && client.PrincipalPhone.Id != id) && countSecondary == 0) { ModelState.AddModelError("Id", GenericError.FORBIDDEN_RESOURCE_OR_DOES_NO_EXIST); return(BadRequest(ModelState)); } if (client.PrincipalPhone != null && client.PrincipalPhone.Id == id) { client.PrincipalPhone = null; await Manager.UpdateAsync(client); } else { client.SecondaryPhone.Remove(phoneNumber); await Manager.UpdateAsync(client); } _repoPhone.Delete(phoneNumber); await _repoPhone.SaveAsync(); return(Ok()); }
/// <summary> /// Deletion of Phone with iD /// </summary> /// <param name="phoneId"></param> private void DeletePhone(long phoneId) { Phone phone = phoneRepository.Find(phoneId); if (phone != null) { phoneRepository.Delete(phone); } }
public async Task <bool> DeletePhoneItem(PhoneViewModel phoneToDelete) { var phone = _mapper.Map <PhoneViewModel, Phone>(phoneToDelete); _repository.Delete(phone); await _repository.CommitAsync(); return(true); }
public async Task <IActionResult> DeleteBrand(int id) { var brand = await _repo.GetPhoneBrand(id); _repo.Delete(brand); await _repo.SaveAll(); return(NoContent()); throw new Exception($"Deleting phone brand failed"); }
public async Task <IActionResult> DeleteModel(int id) { var model = await _repo.GetPhoneModel(id); _repo.Delete(model); await _repo.SaveAll(); return(NoContent()); throw new Exception($"Deleting phone model failed"); }
public async Task <IActionResult> DeleteInventory(int id) { var inventory = await _repo.GetInventory(id); _repo.Delete(inventory); await _repo.SaveAll(); return(NoContent()); throw new Exception($"Deleting inventory details failed"); }
public IActionResult Delete(int id) { var phone = _phoneRepository.GetById(id); if (phone == null) { return(NotFound()); } _phoneRepository.Delete(phone); return(NoContent()); }
public async Task <IActionResult> DeleteSupplier(int id) { var supplier = await _repo.GetSupplier(id); _repo.Delete(supplier); await _repo.SaveAll(); return(NoContent()); throw new Exception($"Deleting supplier failed"); }
public async Task <IActionResult> DeletePhone(int id) { var phone = await _repo.GetPhone(id); _repo.Delete(phone); await _repo.SaveAll(); return(NoContent()); throw new Exception($"Deleting phone details failed"); }
public void DeletePhone(int personId) { /* Not used UnitOfWork attribute, because this method only calls one repository method and repoository can manage it's connection/transaction. */ _phoneRepository.Delete(personId); }
/// <summary> /// Delete Business Partner /// </summary> /// <param name="businessPartner"></param> public void DeleteBusinessPartner(BusinessPartner businessPartner) { BusinessPartner businessPartnerDbVersion = FindBusinessPartner((int)businessPartner.BusinessPartnerId); if (businessPartnerDbVersion == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Business Partner with Id {0} not found!", businessPartner.BusinessPartnerId)); } // delete business partner individual #region delete business partner Individual if (businessPartnerDbVersion.BusinessPartnerIndividual != null) { businessPartnerIndividualRepository.Delete(businessPartnerDbVersion.BusinessPartnerIndividual); } #endregion // delete business partner company #region delete busiess partner company if (businessPartnerDbVersion.BusinessPartnerCompany != null) { businessPartnerCompanyRepository.Delete(businessPartnerDbVersion.BusinessPartnerCompany); } #endregion // delete business partner intypes #region delete business partner intypes List <BusinessPartnerInType> inTypesDeleteList = new List <BusinessPartnerInType>(); foreach (BusinessPartnerInType item in businessPartnerDbVersion.BusinessPartnerInTypes) { inTypesDeleteList.Add(item); } foreach (BusinessPartnerInType itemToDelete in inTypesDeleteList) { businessPartnerInTypeRepository.Delete(itemToDelete); } #endregion // delete business partner phone list #region delete business partner phone list List <Phone> phoneDeleteList = new List <Phone>(); foreach (Phone item in businessPartnerDbVersion.BusinessPartnerPhoneNumbers) { phoneDeleteList.Add(item); } foreach (Phone item in phoneDeleteList) { businessPartnerPhoneRepository.Delete(item); } #endregion // delete business partner address list #region delete business partner address list List <Address> addressDeleteList = new List <Address>(); foreach (Address item in businessPartnerDbVersion.BusinessPartnerAddressList) { addressDeleteList.Add(item); } foreach (Address item in addressDeleteList) { businessPartnerAddressRepository.Delete(item); } #endregion // delete business partner marketing channel #region delete business partner marketing channel List <BusinessPartnerMarketingChannel> marketingChannelDeleteList = new List <BusinessPartnerMarketingChannel>(); foreach (BusinessPartnerMarketingChannel item in businessPartnerDbVersion.BusinessPartnerMarketingChannels) { marketingChannelDeleteList.Add(item); } foreach (BusinessPartnerMarketingChannel item in marketingChannelDeleteList) { businessPartnerMarketingChannelRepository.Delete(item); } #endregion // delete business partner relationship item #region delete business partner relationship item List <BusinessPartnerRelationship> relationshipItemDeleteList = new List <BusinessPartnerRelationship>(); foreach (BusinessPartnerRelationship item in businessPartnerDbVersion.BusinessPartnerRelationshipItemList) { relationshipItemDeleteList.Add(item); } foreach (BusinessPartnerRelationship item in businessPartnerDbVersion.BusinessPartnerRelationshipItemList) { businessPartnerRelationshipRepository.Delete(item); } #endregion // delete business partner businessPartnerRepository.Delete(businessPartnerDbVersion); businessPartnerRepository.SaveChanges(); }
/// <summary> /// Delete /// </summary> /// <param name="id">The id of a record.</param> /// <returns>True if the record was deleted, false otherwise.</returns> public bool Delete(string id) { var myData = repository.Delete(id); return(myData); }
public IActionResult Delete(int id) { Phone phone = _phoneRepository.Delete(id); return(RedirectToAction("index")); }
public void Delete(phone dPhone) { _phoneRepository.Delete(dPhone); }
public void DeletePhoneForPerson(int PhoneId) { phoneRepo.Delete(PhoneId); }
/// <summary> /// Add/Edit Employee /// </summary> /// <param name="employee"></param> /// <returns></returns> public Employee SaveEmployee(Employee employee) { Employee empDbVersion = employeeRepository.Find(employee.EmployeeId); #region Add if (empDbVersion == null) { employee.UserDomainKey = employeeRepository.UserDomainKey; employee.IsActive = true; employee.IsReadOnly = employee.IsPrivate = employee.IsDeleted = false; employee.RecLastUpdatedDt = employee.RecCreatedDt = DateTime.Now; employee.RecLastUpdatedBy = employee.RecCreatedBy = employeeRepository.LoggedInUserIdentity; employee.RowVersion = 0; //Job Info employee.EmpJobInfo.UserDomainKey = employeeRepository.UserDomainKey; employee.EmpJobInfo.IsActive = true; employee.EmpJobInfo.IsReadOnly = employee.EmpJobInfo.IsPrivate = employee.EmpJobInfo.IsDeleted = false; employee.EmpJobInfo.RecLastUpdatedDt = employee.EmpJobInfo.RecCreatedDt = DateTime.Now; employee.EmpJobInfo.RecLastUpdatedBy = employee.EmpJobInfo.RecCreatedBy = employeeRepository.LoggedInUserIdentity; //Address List if (employee.Addresses != null) { foreach (var item in employee.Addresses) { item.UserDomainKey = employeeRepository.UserDomainKey; item.IsActive = true; item.IsReadOnly = item.IsPrivate = item.IsDeleted = false; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; } } //Phone List if (employee.PhoneNumbers != null) { foreach (var item in employee.PhoneNumbers) { item.UserDomainKey = employeeRepository.UserDomainKey; item.IsActive = true; item.IsReadOnly = item.IsPrivate = item.IsDeleted = false; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; } } //Docs Info employee.EmpDocsInfo.UserDomainKey = employeeRepository.UserDomainKey; employee.EmpDocsInfo.IsActive = true; employee.EmpDocsInfo.IsReadOnly = employee.EmpDocsInfo.IsPrivate = employee.EmpDocsInfo.IsDeleted = false; employee.EmpDocsInfo.RecLastUpdatedDt = employee.EmpDocsInfo.RecCreatedDt = DateTime.Now; employee.EmpDocsInfo.RecLastUpdatedBy = employee.EmpDocsInfo.RecCreatedBy = employeeRepository.LoggedInUserIdentity; //Job Progress List if (employee.EmpJobProgs != null) { foreach (var item in employee.EmpJobProgs) { item.UserDomainKey = employeeRepository.UserDomainKey; item.IsActive = true; item.IsReadOnly = item.IsPrivate = item.IsDeleted = false; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; } } //Authorized Locations List if (employee.EmpAuthOperationsWorkplaces != null) { foreach (var item in employee.EmpAuthOperationsWorkplaces) { item.UserDomainKey = employeeRepository.UserDomainKey; item.IsActive = true; item.IsReadOnly = item.IsPrivate = item.IsDeleted = false; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; } } employeeRepository.Add(employee); } #endregion #region Edit else { #region Employee empDbVersion.EmployeeId = employee.EmployeeId; empDbVersion.CompanyId = employee.CompanyId; empDbVersion.EmpStatusId = employee.EmpStatusId; empDbVersion.Gender = employee.Gender; empDbVersion.DOB = employee.DOB; empDbVersion.EmpCode = employee.EmpCode; empDbVersion.EmpFName = employee.EmpFName; empDbVersion.EmpLName = employee.EmpLName; empDbVersion.EmpMName = employee.EmpMName; empDbVersion.Notes = employee.Notes; empDbVersion.Notes1 = employee.Notes1; empDbVersion.Notes2 = employee.Notes2; empDbVersion.Notes3 = employee.Notes3; empDbVersion.Notes4 = employee.Notes4; empDbVersion.Notes5 = employee.Notes5; empDbVersion.NationalityId = employee.NationalityId; empDbVersion.RecLastUpdatedBy = employeeRepository.LoggedInUserIdentity; empDbVersion.RecLastUpdatedDt = DateTime.Now; #endregion #region Emp Job Info empDbVersion.EmpJobInfo.DepartmentId = employee.EmpJobInfo.DepartmentId; empDbVersion.EmpJobInfo.DesigGradeId = employee.EmpJobInfo.DesigGradeId; empDbVersion.EmpJobInfo.DesignationId = employee.EmpJobInfo.DesignationId; empDbVersion.EmpJobInfo.JobTypeId = employee.EmpJobInfo.JobTypeId; empDbVersion.EmpJobInfo.SupervisorId = employee.EmpJobInfo.SupervisorId; empDbVersion.EmpJobInfo.WorkPlaceId = employee.EmpJobInfo.WorkPlaceId; empDbVersion.EmpJobInfo.JoiningDt = employee.EmpJobInfo.JoiningDt; empDbVersion.EmpJobInfo.Salary = employee.EmpJobInfo.Salary; empDbVersion.EmpJobInfo.RecLastUpdatedBy = employeeRepository.LoggedInUserIdentity; empDbVersion.EmpJobInfo.RecLastUpdatedDt = DateTime.Now; #endregion #region Emp Docs Info empDbVersion.EmpDocsInfo.InsuranceCompany = employee.EmpDocsInfo.InsuranceCompany; empDbVersion.EmpDocsInfo.InsuranceDt = employee.EmpDocsInfo.InsuranceDt; empDbVersion.EmpDocsInfo.InsuranceNo = employee.EmpDocsInfo.InsuranceNo; empDbVersion.EmpDocsInfo.IqamaExpDt = employee.EmpDocsInfo.IqamaExpDt; empDbVersion.EmpDocsInfo.IqamaNo = employee.EmpDocsInfo.IqamaNo; empDbVersion.EmpDocsInfo.LicenseExpDt = employee.EmpDocsInfo.LicenseExpDt; empDbVersion.EmpDocsInfo.LicenseNo = employee.EmpDocsInfo.LicenseNo; empDbVersion.EmpDocsInfo.LicenseTypeId = employee.EmpDocsInfo.LicenseTypeId; empDbVersion.EmpDocsInfo.PassportCountryId = employee.EmpDocsInfo.PassportCountryId; empDbVersion.EmpDocsInfo.VisaIssueCountryId = employee.EmpDocsInfo.VisaIssueCountryId; empDbVersion.EmpDocsInfo.PassportNo = employee.EmpDocsInfo.PassportNo; empDbVersion.EmpDocsInfo.PassportExpDt = employee.EmpDocsInfo.PassportExpDt; empDbVersion.EmpDocsInfo.VisaNo = employee.EmpDocsInfo.VisaNo; empDbVersion.EmpDocsInfo.VisaExpDt = employee.EmpDocsInfo.VisaExpDt; empDbVersion.EmpDocsInfo.RecLastUpdatedBy = employeeRepository.LoggedInUserIdentity; empDbVersion.EmpDocsInfo.RecLastUpdatedDt = DateTime.Now; #endregion #region Address List if (employee.Addresses != null) { foreach (var item in employee.Addresses) { if ( empDbVersion.Addresses.All( x => x.AddressId != item.AddressId || item.AddressId == 0)) { item.UserDomainKey = employeeRepository.UserDomainKey; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; empDbVersion.Addresses.Add(item); } } } //find missing items List <Address> missingAddressItems = new List <Address>(); foreach (Address dbversionAddressItem in empDbVersion.Addresses) { if (employee.Addresses != null && employee.Addresses.All(x => x.AddressId != dbversionAddressItem.AddressId)) { missingAddressItems.Add(dbversionAddressItem); } if (employee.Addresses == null) { missingAddressItems.Add(dbversionAddressItem); } } //remove missing items foreach (Address missingAddressItem in missingAddressItems) { Address dbVersionMissingItem = empDbVersion.Addresses.First(x => x.AddressId == missingAddressItem.AddressId); if (dbVersionMissingItem.AddressId > 0) { empDbVersion.Addresses.Remove(dbVersionMissingItem); addressRepository.Delete(dbVersionMissingItem); addressRepository.SaveChanges(); } } #endregion #region Phone List if (employee.PhoneNumbers != null) { foreach (var item in employee.PhoneNumbers) { if ( empDbVersion.PhoneNumbers.All( x => x.PhoneId != item.PhoneId || item.PhoneId == 0)) { item.UserDomainKey = employeeRepository.UserDomainKey; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; empDbVersion.PhoneNumbers.Add(item); } } } //find missing items List <Phone> missingPhoneItems = new List <Phone>(); foreach (Phone dbversionPhoneItem in empDbVersion.PhoneNumbers) { if (employee.PhoneNumbers != null && employee.PhoneNumbers.All(x => x.PhoneId != dbversionPhoneItem.PhoneId)) { missingPhoneItems.Add(dbversionPhoneItem); } if (employee.PhoneNumbers == null) { missingPhoneItems.Add(dbversionPhoneItem); } } //remove missing items foreach (Phone missingPhoneItem in missingPhoneItems) { Phone dbVersionMissingItem = empDbVersion.PhoneNumbers.First(x => x.PhoneId == missingPhoneItem.PhoneId); if (dbVersionMissingItem.PhoneId > 0) { empDbVersion.PhoneNumbers.Remove(dbVersionMissingItem); phoneRepository.Delete(dbVersionMissingItem); phoneRepository.SaveChanges(); } } #endregion #region Docs Info employee.EmpDocsInfo.UserDomainKey = employeeRepository.UserDomainKey; employee.EmpDocsInfo.IsActive = true; employee.EmpDocsInfo.IsReadOnly = employee.EmpDocsInfo.IsPrivate = employee.EmpDocsInfo.IsDeleted = false; employee.EmpDocsInfo.RecLastUpdatedDt = employee.EmpDocsInfo.RecCreatedDt = DateTime.Now; employee.EmpDocsInfo.RecLastUpdatedBy = employee.EmpDocsInfo.RecCreatedBy = employeeRepository.LoggedInUserIdentity; #endregion #region Job Progress List if (employee.EmpJobProgs != null) { foreach (var item in employee.EmpJobProgs) { if ( empDbVersion.EmpJobProgs.All( x => x.EmpJobProgId != item.EmpJobProgId || item.EmpJobProgId == 0)) { item.UserDomainKey = employeeRepository.UserDomainKey; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; empDbVersion.EmpJobProgs.Add(item); } } } //find missing items List <EmpJobProg> missingEmpJobProgItems = new List <EmpJobProg>(); foreach (EmpJobProg dbversionEmpJobProgItem in empDbVersion.EmpJobProgs) { if (employee.EmpJobProgs != null && employee.EmpJobProgs.All(x => x.EmpJobProgId != dbversionEmpJobProgItem.EmpJobProgId)) { missingEmpJobProgItems.Add(dbversionEmpJobProgItem); } if (employee.EmpJobProgs == null) { missingEmpJobProgItems.Add(dbversionEmpJobProgItem); } } //remove missing items foreach (EmpJobProg missingEmpJobProgItem in missingEmpJobProgItems) { EmpJobProg dbVersionMissingItem = empDbVersion.EmpJobProgs.First(x => x.EmpJobProgId == missingEmpJobProgItem.EmpJobProgId); if (dbVersionMissingItem.EmpJobProgId > 0) { empDbVersion.EmpJobProgs.Remove(dbVersionMissingItem); empJobProgRepository.Delete(dbVersionMissingItem); empJobProgRepository.SaveChanges(); } } #endregion #region Authorized Locations List if (employee.EmpAuthOperationsWorkplaces != null) { foreach (var item in employee.EmpAuthOperationsWorkplaces) { if ( empDbVersion.EmpAuthOperationsWorkplaces.All( x => x.EmpAuthOperationsWorkplaceId != item.EmpAuthOperationsWorkplaceId || item.EmpAuthOperationsWorkplaceId == 0)) { item.UserDomainKey = employeeRepository.UserDomainKey; item.RecLastUpdatedDt = item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedBy = item.RecCreatedBy = employeeRepository.LoggedInUserIdentity; item.RowVersion = 0; empDbVersion.EmpAuthOperationsWorkplaces.Add(item); } } } //find missing items List <EmpAuthOperationsWorkplace> missingLocationItems = new List <EmpAuthOperationsWorkplace>(); foreach (EmpAuthOperationsWorkplace dbversionLocationItem in empDbVersion.EmpAuthOperationsWorkplaces) { if (employee.EmpAuthOperationsWorkplaces != null && employee.EmpAuthOperationsWorkplaces.All(x => x.EmpAuthOperationsWorkplaceId != dbversionLocationItem.EmpAuthOperationsWorkplaceId)) { missingLocationItems.Add(dbversionLocationItem); } if (employee.EmpAuthOperationsWorkplaces == null) { missingLocationItems.Add(dbversionLocationItem); } } //remove missing items foreach (EmpAuthOperationsWorkplace missingLocationItem in missingLocationItems) { EmpAuthOperationsWorkplace dbVersionMissingItem = empDbVersion.EmpAuthOperationsWorkplaces.First(x => x.EmpAuthOperationsWorkplaceId == missingLocationItem.EmpAuthOperationsWorkplaceId); if (dbVersionMissingItem.EmpAuthOperationsWorkplaceId > 0) { empDbVersion.EmpAuthOperationsWorkplaces.Remove(dbVersionMissingItem); empAuthOperationsWorkplaceRepository.Delete(dbVersionMissingItem); empAuthOperationsWorkplaceRepository.SaveChanges(); } } #endregion } #endregion employeeRepository.SaveChanges(); return(employeeRepository.Find(employee.EmployeeId)); }