コード例 #1
0
        public void DeleteHoliday(HolidayVM value)
        {
            var data = ObjectMapper.Mapper.Map <Holiday>(value);

            _stockMarketUow.HolidayRepo.Delete(data);
            _stockMarketUow.Save();
        }
コード例 #2
0
        private void RepopulateListsFromCacheSession(HolidayVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            HolidayLookupListsCacheObject CachedLists = CacheManager.HolidayListCache;

            // Retrieve any cached lists to model
        }
コード例 #3
0
        public string UpdateHoliday(HolidayVM holiday)
        {
            string holidayId = string.Empty;

            SqlParameter[] parameters =
            {
                new SqlParameter {
                    ParameterName = "@Id", Value = holiday.Id
                },
                new SqlParameter {
                    ParameterName = "@Date", Value = holiday.Date
                },
                new SqlParameter {
                    ParameterName = "@Title", Value = holiday.Title
                },
                new SqlParameter {
                    ParameterName = "@Description", Value = holiday.Description
                },
                new SqlParameter {
                    ParameterName = "@IsActive", Value = holiday.IsActive
                },
                new SqlParameter {
                    ParameterName = "@UpdatedBy", Value = holiday.UpdatedBy
                }
            };

            holidayId = Convert.ToString(DALHelper.ExecuteScalar("UpdateHoliday", parameters));

            return(holidayId);
        }
コード例 #4
0
 public static Holiday UVMToUM(HolidayVM vm, Holiday m)
 {
     m.Description = vm.Description;
     m.StartDate   = DataVerification.IsNull(vm.StartDate) ? new DateTime() : Convert.ToDateTime(vm.StartDate);
     m.EndDate     = DataVerification.IsNull(vm.EndDate) ? new DateTime() : Convert.ToDateTime(vm.EndDate);
     return(m);
 }
コード例 #5
0
ファイル: Holiday.cs プロジェクト: ssatyaji/LeaveRequest
 public Holiday(HolidayVM holidayVM)
 {
     this.HolidayDate = holidayVM.HolidayDate;
     this.HolidayName = holidayVM.HolidayName;
     this.Day         = holidayVM.Day;
     this.CreateDate  = DateTimeOffset.Now.LocalDateTime;
 }
コード例 #6
0
ファイル: Holiday.cs プロジェクト: ssatyaji/LeaveRequest
 public void Update(HolidayVM holidayVM)
 {
     this.HolidayDate = holidayVM.HolidayDate;
     this.HolidayName = holidayVM.HolidayName;
     this.Day         = holidayVM.Day;
     this.UpdateDate  = DateTimeOffset.Now.LocalDateTime;
 }
コード例 #7
0
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private HolidayVM GetUpdatedModel()
        {
            HolidayVM model = new HolidayVM();

            RepopulateListsFromCacheSession(model);
            model.Message = "";

            if (SessionManager.CurrentHoliday != null)
            {
                model.HolidayItem = SessionManager.CurrentHoliday;
            }

            //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING **************************
            bool result = TryUpdateModel(model);//This also validates and sets ModelState

            //*******************************************************************************************************************************
            if (SessionManager.CurrentHoliday != null)
            {
                //*****************************************PREVENT OVER POSTING ATTACKS******************************************************
                //Get the values for read only fields from session
                MergeNewValuesWithOriginal(model.HolidayItem);
                //***************************************************************************************************************************
            }

            SetAccessContext(model);

            return(model);
        }
コード例 #8
0
        public bool Insert(HolidayVM holidayVM)
        {
            var push = new Holiday(holidayVM);

            applicationContext.Holidays.Add(push);
            var result = applicationContext.SaveChanges();

            return(result > 0);
        }
コード例 #9
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = SessionManager.HolidayCode;

            HolidayVM model = new HolidayVM();

            // Not from staff or error
            if (String.IsNullOrEmpty(code))
            {
                //If session has lists then use them
                RepopulateListsFromCacheSession(model);

                //Assume we are in create mode as no code passed
                model.HolidayItem = new HolidayModel()
                {
                    IsActive = true
                };
            }
            //if we have been passed a code then assume we are in edit situation and we need to retrieve from the database.
            else
            {
                // Create service instance
                AdminServiceClient sc = new AdminServiceClient();

                try
                {
                    // Call service to get Holiday item and any associated lookups
                    HolidayVMDC returnedObject = sc.GetHoliday(CurrentUser, CurrentUser, appID, "", code);

                    // Close service communication
                    sc.Close();

                    //Get view model from service
                    model = ConvertHolidayDC(returnedObject);

                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    //Store the service version
                    SessionManager.HolidayServiceVersion = model.HolidayItem;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            //Adds current retrieved Holiday to session
            SessionManager.CurrentHoliday = model.HolidayItem;
            SetAccessContext(model);

            return(View(model));
        }
コード例 #10
0
ファイル: HolidayFacade.cs プロジェクト: sanlonezhang/ql
        public void CreateHoliday(HolidayVM _viewInfo, EventHandler <RestClientEventArgs <dynamic> > callback)
        {
            string relativeUrl = "/CommonService/Holiday/Create";
            var    msg         = _viewInfo.ConvertVM <HolidayVM, Holiday>();

            msg.CreateUserSysNo = CPApplication.Current.LoginUser.UserSysNo;
            msg.CreateUserName  = CPApplication.Current.LoginUser.LoginName;
            restClient.Create(relativeUrl, msg, callback);
        }
コード例 #11
0
        private void SetFlagsFalse(HolidayVM model)
        {
            model.IsExitConfirmed = "False";
            model.IsNewConfirmed  = "False";

            //Stop the binder resetting the posted values
            ModelState.Remove("IsDeleteConfirmed");
            ModelState.Remove("IsExitConfirmed");
            ModelState.Remove("IsNewConfirmed");
        }
コード例 #12
0
 public static Holiday VMToM(HolidayVM vm)
 {
     return(new Holiday()
     {
         ID = vm.ID,
         Description = vm.Description,
         StartDate = DataVerification.IsNull(vm.StartDate) ? new DateTime() : Convert.ToDateTime(vm.StartDate),
         EndDate = DataVerification.IsNull(vm.EndDate) ? new DateTime() : Convert.ToDateTime(vm.EndDate),
         CompanyID = vm.Company.ID
     });
 }
コード例 #13
0
        private HolidayVM ConvertHolidayDC(HolidayVMDC returnedObject)
        {
            HolidayVM model = new HolidayVM();

            // Map Holiday Item
            model.HolidayItem = Mapper.Map <HolidayDC, HolidayModel>(returnedObject.HolidayItem);

            // Map lookup data lists

            return(model);
        }
コード例 #14
0
 public async Task <JsonResult> Update(HolidayVM vm)
 {
     try {
         var list = _holidayService.GetAll();
         list = HolidayUtility.FilterByCompanyID(CurrentUser.CompanyID, list);
         //verify if conflict with other holidays
         var model = _holidayService.GetByID(vm.ID);
         model = HolidayUtility.UVMToUM(vm, model);
         _holidayService.Update(model);
         return(Json(new { success = true, data = HolidayUtility.MToVM(model) }));
     } catch { return(Json(new { success = false })); }
 }
コード例 #15
0
 private void DetermineIsDirty(HolidayVM model)
 {
     //Compare the Holiday to the original session
     if (model.HolidayItem.PublicInstancePropertiesEqual(SessionManager.HolidayServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
コード例 #16
0
 private void SetAccessContext(HolidayVM model)
 {
     //Decide on access context
     if (null == model.HolidayItem || model.HolidayItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = HolidayAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = HolidayAccessContext.Edit;
     }
 }
コード例 #17
0
        public ActionResult SaveHoliday(HolidayVM HolidayMaster)
        {
            List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>;

            if (list == null)
            {
                return(Redirect("Login/InLogin"));
            }
            else
            {
                HolidayMaster.CmpyCode = list[0].CmpyCode;
                HolidayMaster.UserName = list[0].user_name;
                return(Json(_HoliService.SaveHoliday(HolidayMaster), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #18
0
        public ActionResult Edit(Guid id)
        {
            var holiday = holidayRepository.GetHolidayById(id);

            HolidayVM model = new HolidayVM();

            if (holiday != null && holiday.Count > 0)
            {
                model = holiday[0];

                return(View(model));
            }

            return(RedirectToAction("List"));
        }
コード例 #19
0
        public bool Update(int id, HolidayVM holidayVM)
        {
            var get = Get(id);

            if (get != null)
            {
                get.Update(holidayVM);
                applicationContext.Entry(get).State = EntityState.Modified;
                var result = applicationContext.SaveChanges();
                return(result > 0);
            }
            else
            {
                return(false);
            }
        }
コード例 #20
0
        public async Task <JsonResult> Insert(HolidayVM vm)
        {
            try {
                var list = _holidayService.GetAll();
                list = HolidayUtility.FilterByCompanyID(CurrentUser.CompanyID, list);
                //verify if conflict with other holidays

                vm.ID      = Guid.NewGuid().ToString();
                vm.Company = new CompanyViewModel()
                {
                    ID = CurrentUser.CompanyID
                };
                var model = HolidayUtility.VMToM(vm);
                _holidayService.Insert(model);
                return(Json(new { success = true }));
            } catch { return(Json(new { success = false })); }
        }
コード例 #21
0
        public ActionResult UpdateHoliday([FromBody] HolidayVM value)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _stockMarketBusinessSevice.UpdateHoliday(value);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
コード例 #22
0
        public ActionResult Create(HolidayVM model)
        {
            try
            {
                string holidayId = string.Empty;
                model.CreatedBy = LogInManager.LoggedInUserId;

                holidayId = holidayRepository.AddHoliday(model);

                if (!string.IsNullOrWhiteSpace(holidayId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            HolidayId = holidayId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Holiday details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
コード例 #23
0
 public bool Insert(HolidayVM holidayVM)
 {
     return(iHolidayRepository.Insert(holidayVM));
 }
コード例 #24
0
        public HolidayVM SaveHoliday(HolidayVM Hol)
        {
            DateTime dt1;

            try
            {
                if (!Hol.EditFlag)
                {
                    var Drecord = new List <string>();
                    List <HolidayDetailnew> ObjList = new List <HolidayDetailnew>();
                    ObjList.AddRange(Hol.HolidayDetailnew.Select(m => new HolidayDetailnew
                    {
                        CmpyCode       = m.CmpyCode,
                        Dates          = m.Dates,
                        COUNTRY        = m.COUNTRY,
                        LEAVE_TYPECODE = m.LEAVE_TYPECODE,
                        Description    = m.Description,
                        HRPH001_CODE   = m.HRPH001_CODE
                    }).ToList());
                    int n = 0;
                    n = ObjList.Count;
                    string dtstr;
                    while (n > 0)
                    {
                        dt1 = Convert.ToDateTime(ObjList[n - 1].Dates);

                        dtstr = dt1.ToString("yyyy-MM-dd");


                        int Atens1 = _EzBusinessHelper.ExecuteScalar("Select count(*) as [count1] from HRPH001 where CmpyCode='" + Hol.CmpyCode + "' and format(Holiday_date,'dd-MM-yyyy')=format(cast('" + dtstr + "'  as date),'dd-MM-yyyy')");
                        if (Atens1 == 0)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append("'" + Hol.CmpyCode + "',");
                            sb.Append("'" + dtstr + "',");
                            sb.Append("'" + ObjList[n - 1].COUNTRY + "',");
                            sb.Append("'" + ObjList[n - 1].LEAVE_TYPECODE + "',");
                            sb.Append("'" + ObjList[n - 1].Description + "',");
                            sb.Append("'" + ObjList[n - 1].HRPH001_CODE + "')");

                            _EzBusinessHelper.ExecuteNonQuery("insert into HRPH001(CmpyCode,Holiday_date,COUNTRY,LEAVE_TYPE,Description,HRPH001_CODE) values(" + sb.ToString() + "");

                            _EzBusinessHelper.ActivityLog(Hol.CmpyCode, Hol.UserName, "Add Holiday", dtstr, Environment.MachineName);

                            Hol.SaveFlag     = true;
                            Hol.ErrorMessage = string.Empty;
                        }
                        else
                        {
                            Drecord.Add(dtstr);

                            Hol.Drecord      = Drecord;
                            Hol.SaveFlag     = false;
                            Hol.ErrorMessage = "Duplicate Record";
                        }
                        n = n - 1;
                    }


                    return(Hol);
                }

                dt1 = Convert.ToDateTime(Hol.Dates);


                string dtstr1 = dt1.ToString("yyyy-MM-dd hh:mm:ss tt");
                // and format(Holiday_date,'dd-MM-yyyy')=format(cast('" + dtstr1 + "'  as date),'dd-MM-yyyy')
                var StatsEdit = _EzBusinessHelper.ExecuteScalar("Select count(*) from HRPH001 where CmpyCode='" + Hol.CmpyCode + "' and HRPH001_CODE='" + Hol.HRPH001_CODE + "'");
                if (StatsEdit != 0)
                {
                    //and format(Holiday_date,'dd-MM-yyyy')=format(cast('" + dtstr1 + "'  as date),'dd-MM-yyyy')
                    _EzBusinessHelper.ExecuteNonQuery("update HRPH001 set CmpyCode='" + Hol.CmpyCode + "',Holiday_date='" + dtstr1 + "',COUNTRY='" + Hol.COUNTRY + "',LEAVE_TYPE='" + Hol.LEAVE_TYPECODE + "',Description='" + Hol.Description + "' where HRPH001_CODE='" + Hol.HRPH001_CODE + "' and  CmpyCode='" + Hol.CmpyCode + "' ");

                    _EzBusinessHelper.ActivityLog(Hol.CmpyCode, Hol.UserName, "Update Holiday", Hol.Dates, Environment.MachineName);

                    Hol.SaveFlag     = true;
                    Hol.ErrorMessage = string.Empty;
                }
                else
                {
                    Hol.SaveFlag     = false;
                    Hol.ErrorMessage = "Record not available";
                }
            }
            catch (Exception ex)
            {
                Hol.SaveFlag = false;
                //  unit.ErrorMessage = exceptionMessage;
            }


            return(Hol);
        }
コード例 #25
0
 void UCAddHoliday_Loaded(object sender, RoutedEventArgs e)
 {
     VM = new HolidayVM();
     LayoutRoot.DataContext = VM;
 }
コード例 #26
0
 public void AddHoliday(HolidayVM value)
 {
     _stockMarketDataSevice.AddHoliday(value);
 }
コード例 #27
0
 public void UpdateHoliday(HolidayVM value)
 {
     _stockMarketDataSevice.UpdateHoliday(value);
 }
コード例 #28
0
 public void DeleteHoliday(HolidayVM value)
 {
     _stockMarketDataSevice.DeleteHoliday(value);
 }
コード例 #29
0
 private void ResolveFieldCodesToFieldNamesUsingLists(HolidayVM model)
 {
     //TODO:
 }
コード例 #30
0
 public bool Update(int id, HolidayVM holidayVM)
 {
     return(iHolidayRepository.Update(id, holidayVM));
 }