public void ServiceOutsideDetailSave(ServiceOutsideDTO serviceOutsideDTO, ServiceOutside serviceOutside) { var listNewServiceOutsideDetailId = new List <int>(); foreach (var serviceOutsideDetailDTO in serviceOutsideDTO.listServiceOutsideDetailDTO) { ServiceOutsideDetail serviceOutsideDetail = null; var unitPrice = 0.0; try { unitPrice = Double.Parse(serviceOutsideDetailDTO.unitPrice); } catch { } var quantity = 0; try { quantity = Convert.ToInt32(serviceOutsideDetailDTO.quantity); } catch { } var totalPrice = 0.0; try { totalPrice = Double.Parse(serviceOutsideDetailDTO.totalPrice); } catch { } if (serviceOutsideDetailDTO.id <= 0) { serviceOutsideDetail = new ServiceOutsideDetail(); } else if (serviceOutsideDetailDTO.id > 0) { serviceOutsideDetail = BookingViewingBLL.ServiceOutsideDetailGetById(serviceOutsideDetailDTO.id); } serviceOutsideDetail.Name = serviceOutsideDetailDTO.name; serviceOutsideDetail.UnitPrice = unitPrice; serviceOutsideDetail.Quantity = quantity; serviceOutside.TotalPrice = totalPrice; serviceOutsideDetail.ServiceOutside = serviceOutside; BookingViewingBLL.ServiceOutsideDetailSaveOrUpdate(serviceOutsideDetail); listNewServiceOutsideDetailId.Add(serviceOutsideDetail.Id); var listServiceOutsideDetail = BookingViewingBLL.ServiceOutsideDetailGetAllByServiceOutsideId(serviceOutside.Id); var listIdOfServiceOutsideDetail = listServiceOutsideDetail.Select(x => x.Id).ToList(); var listIdOfServiceOutsideDetailDTO = serviceOutsideDTO.listServiceOutsideDetailDTO.Where(x => x.id > 0).Select(x => x.id).ToList(); var listServiceOutsideDetailIdNeedRemove = listIdOfServiceOutsideDetail.Except(listIdOfServiceOutsideDetailDTO).Except(listNewServiceOutsideDetailId); foreach (var serviceOutsideDetailIdNeedRemove in listServiceOutsideDetailIdNeedRemove) { var serviceOutsideDetailNeedRemove = BookingViewingBLL.ServiceOutsideDetailGetById(serviceOutsideDetailIdNeedRemove); BookingViewingBLL.ServiceOutsideDetailDelete(serviceOutsideDetailNeedRemove); } Dispose(); } }
public void ServiceOutsideDetailDelete(ServiceOutsideDetail serviceOutsideDetail) { ServiceOutsideDetailRepository.Delete(serviceOutsideDetail); }
public void ServiceOutsideDetailSaveOrUpdate(ServiceOutsideDetail serviceOutsideDetail) { ServiceOutsideDetailRepository.SaveOrUpdate(serviceOutsideDetail); }