Пример #1
0
        public AmplifyingReportView Add(Subscriber SubsModel, string UserName, AmplifyingReport ARModel)
        {
            try
            {
                if (SubsModel == null)
                {
                    throw new Exception("Subscriber model is null");
                }
                else if (ARModel == null)
                {
                    throw new Exception("Preliminary report model is null");
                }

                using (AmplifyingReportRepository ARRepo = new AmplifyingReportRepository())
                {
                    AmplifyingReportView ARView        = new AmplifyingReportView();
                    string coiNumber                   = "";
                    List <AmplifyingReportView> lstARs = ARRepo.GetList <AmplifyingReportView>(new { COI_ID = ARModel.COIId }).ToList();

                    using (COIRepository coiRepo = new COIRepository())
                    {
                        coiNumber = coiRepo.Get <COI>(ARModel.COIId).COINumber;
                    }
                    string generatedARNo = coiNumber + "-AR-" + 1;

                    ARView = lstARs.OrderByDescending(x => x.ARId).FirstOrDefault();
                    if (ARView != null)
                    {
                        generatedARNo = Common.GetNextSubReportNumber(ARView.ARNumber);
                    }

                    ARModel.ARNumber             = generatedARNo;
                    ARModel.ActionAddressee      = string.Join(",", ARModel.ActionAddresseeArray);
                    ARModel.InformationAddressee = string.Join(",", ARModel.InformationAddresseeArray);
                    ARModel.ReportingDatetime    = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    ARModel.SubscriberId         = SubsModel.SubscriberId;
                    ARModel.CreatedOn            = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubsModel.SubscriberId));
                    ARModel.CreatedBy            = UserName;

                    int rowId = ARRepo.Insert(ARModel);
                    return(ARView = GetById(rowId));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 public bool Update(int SubscriberId, string UserName, AmplifyingReport ARModel)
 {
     try
     {
         using (AmplifyingReportRepository ARRepo = new AmplifyingReportRepository())
         {
             ARModel.LastModifiedOn = Common.GetLocalDateTime(MemCache.GetFromCache <string>("Timezone_" + SubscriberId));
             ARModel.LastModifiedBy = UserName;
             ARRepo.Update <AmplifyingReport>(ARModel);
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }