/// <summary> /// This method is used to save the transmitter fees details /// </summary> /// <param name="tmDto"></param> /// <param name="RefID"></param> /// <returns></returns> public bool SaveCustomerAssociatedFees(TransmitterFeeDTO tmDto) { bool iretval = false; //int entityState = 0; try { if (tmDto != null) { Guid refId; bool IsRefId1 = Guid.TryParse(tmDto.refId, out refId); var FeeMasterEntity = db.FeeMasters; List <CustomerAssociatedFee> customerassociatedfeelst = new List <CustomerAssociatedFee>(); foreach (var itm in FeeMasterEntity) { if (db.CustomerAssociatedFees.Where(a => a.FeeMaster_ID == itm.Id && a.emp_CustomerInformation_ID == refId).Count() == 0) { CustomerAssociatedFee customerassociatedfee = new CustomerAssociatedFee(); Guid newGenId = Guid.NewGuid(); customerassociatedfee.ID = newGenId; customerassociatedfee.emp_CustomerInformation_ID = refId; customerassociatedfee.FeeMaster_ID = itm.Id; customerassociatedfee.Amount = itm.Amount ?? 0; customerassociatedfee.IsActive = true; if (itm.FeeTypeId == 2) { customerassociatedfee.IsEdit = true; } else { customerassociatedfee.IsEdit = false; } customerassociatedfee.CreatedBy = tmDto.UserId ?? Guid.Empty; customerassociatedfee.CreatedDate = System.DateTime.Now; customerassociatedfee.LastUpdatedBy = tmDto.UserId ?? Guid.Empty; customerassociatedfee.LastUpdatedDate = System.DateTime.Now; customerassociatedfeelst.Add(customerassociatedfee); } } if (customerassociatedfeelst.Count > 0) { db.CustomerAssociatedFees.AddRange(customerassociatedfeelst); db.SaveChanges(); } iretval = true; } } catch (Exception ex) { EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/GetSubSiteBankFeeById", Guid.Empty); return(false); } return(iretval); }
public IHttpActionResult PostCustomerAssociateFees(TransmitterFeeDTO oDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = subsitefeeService.SaveCustomerAssociatedFees(oDto); return(Ok(result)); }
/// <summary> /// This Method is used to update Amount for Customer Associated Fees /// </summary> /// <param name="tmDto"></param> /// <returns></returns> public bool UpdateCustomerAssociatedFees(TransmitterFeeDTO tmDto) { bool iretval = false; //int entityState = 0; try { if (tmDto != null) { Guid newguid, newguid2; bool IsRefId = Guid.TryParse(tmDto.FeeMaster_ID, out newguid2); bool IsRefId1 = Guid.TryParse(tmDto.refId, out newguid); CustomerAssociatedFee customerassociatedfee = new CustomerAssociatedFee(); var data = db.CustomerAssociatedFees.Where(a => a.emp_CustomerInformation_ID == newguid && a.FeeMaster_ID == newguid2 && a.IsActive == true).FirstOrDefault(); if (data != null) { customerassociatedfee = data; customerassociatedfee.LastUpdatedBy = tmDto.UserId ?? Guid.Empty; customerassociatedfee.LastUpdatedDate = System.DateTime.Now; customerassociatedfee.IsActive = false; db.Entry(customerassociatedfee).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); db.Dispose(); //EMP.Core.Utilities.AuditLogger.AudittrailLog(customerassociatedfee, data, "Modify", tmDto.UserId ?? Guid.Empty); } db = new DatabaseEntities(); CustomerAssociatedFee customerassociatedfeeSave = new CustomerAssociatedFee(); customerassociatedfeeSave = data; customerassociatedfeeSave.ID = Guid.NewGuid(); customerassociatedfeeSave.Amount = tmDto.Amount; customerassociatedfeeSave.IsActive = true; customerassociatedfeeSave.CreatedBy = tmDto.UserId ?? Guid.Empty; customerassociatedfeeSave.CreatedDate = System.DateTime.Now; customerassociatedfeeSave.LastUpdatedBy = tmDto.UserId ?? Guid.Empty; customerassociatedfeeSave.LastUpdatedDate = System.DateTime.Now; db.CustomerAssociatedFees.Add(customerassociatedfeeSave); db.SaveChanges(); db.Dispose(); //EMP.Core.Utilities.AuditLogger.AudittrailLog(customerassociatedfeeSave, null, "Add", tmDto.UserId ?? Guid.Empty); iretval = true; } } catch (Exception ex) { EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/UpdateCustomerAssociatedFees", Guid.Empty); return(false); } return(iretval); }