public ActionResult PopupInsert(MPacketComm viewModel, FormCollection formCollection, string EmployeeId) { UpdateNumericData(viewModel, formCollection); MPacketComm packetComm = new MPacketComm(); TransferFormValuesTo(packetComm, viewModel, formCollection, EmployeeId); packetComm.SetAssignedIdTo(Guid.NewGuid().ToString()); packetComm.CreatedDate = DateTime.Now; packetComm.CreatedBy = User.Identity.Name; packetComm.DataStatus = EnumDataStatus.New.ToString(); //IList<MItemUom> listItemUom = new List<MItemUom>(); //mItemToInsert.ItemUoms = listItemUom; _mPacketCommRepository.Save(packetComm); try { _mPacketCommRepository.DbContext.CommitChanges(); } catch (Exception e) { _mPacketCommRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("Data komisi paket berhasil disimpan")); }
private void TransferFormValuesTo(MPacketComm packetComm, MPacketComm viewModel, FormCollection formCollection, string EmployeeId) { packetComm.PacketId = _mPacketRepository.Get(formCollection["PacketId"]); packetComm.EmployeeId = _mEmployeeRepository.Get(EmployeeId); packetComm.PacketCommVal = viewModel.PacketCommVal; packetComm.PacketCommType = viewModel.PacketCommType; packetComm.PacketCommStatus = viewModel.PacketCommStatus; packetComm.PacketCommDesc = viewModel.PacketCommDesc; }
private void UpdateNumericData(MPacketComm viewModel, FormCollection formCollection) { if (!string.IsNullOrEmpty(formCollection["PacketCommVal"])) { string PacketCommVal = formCollection["PacketCommVal"].Replace(",", ""); viewModel.PacketCommVal = Convert.ToDecimal(PacketCommVal); } else { viewModel.PacketCommVal = null; } }
/// <summary> /// calculate commission, /// if packet commission available, use it, /// else use global commission /// </summary> /// <param name="emp"></param> /// <param name="packet"></param> /// <param name="totalTrans"></param> /// <returns></returns> private decimal?CalculateCommission(MEmployee emp, MPacket packet, decimal?totalTrans) { decimal? commission = 0; string typeCommission = emp.EmployeeCommissionServiceType; decimal? commissionVal = emp.EmployeeCommissionServiceVal; MPacketComm packetComm = _mPacketCommRepository.GetByEmployeeAndPacket(emp, packet); if (packetComm != null) { typeCommission = packetComm.PacketCommType; commissionVal = packetComm.PacketCommVal; } if (typeCommission == EnumCommissionType.Percent.ToString()) { commission = totalTrans * (commissionVal / 100); } else { commission = commissionVal; } return(commission); }
public ActionResult PopupDelete(MPacketComm viewModel, FormCollection formCollection) { MPacketComm packetComm = _mPacketCommRepository.Get(viewModel.Id); if (packetComm != null) { _mPacketCommRepository.Delete(packetComm); } try { _mPacketCommRepository.DbContext.CommitChanges(); } catch (Exception e) { _mPacketCommRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("Data komisi paket berhasil dihapus")); }