Пример #1
0
 public static void RemoveCache(T_LMS_Master_AnnualLeave objItem)
 {
     HttpCache.RemoveByPattern(SETTINGS_ALL_KEY);
     HttpCache.RemoveByPattern(string.Format(SETTINGS_ID_KEY, objItem.Grade_Id));
     //HttpCache.RemoveByPattern(string.Format(SETTINGS_User_KEY, objItem.CreatedUser));
     HttpCache.RemoveSearchCache(SystemConfig.AllowSearchCache, SETTINGS_Search_KEY);
 }
Пример #2
0
 public ActionResult Create(T_LMS_Master_AnnualLeave model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //  model.CreatedUser = CurrentUser.UserName;
             if (model.Grade_Id != 0)
             {
                 //get default value
                 //	T_LMS_Master_AnnualLeave b = T_LMS_Master_AnnualLeaveManager.GetById(model.ID);
                 T_LMS_Master_AnnualLeaveManager.Update(model);
             }
             else
             {
                 // TODO: Add insert logic here
                 //	 model.CreatedDate = SystemConfig.CurrentDate;
                 T_LMS_Master_AnnualLeaveManager.Add(model);
             }
             return(View(ViewFolder + "list.cshtml", T_LMS_Master_AnnualLeaveManager.GetAll()));
         }
     }
     catch
     {
         return(View(model));
     }
     return(View(model));
 }
Пример #3
0
        public ContentResult Save(string objdata, string value)
        {
            JsonObject js = new JsonObject();

            js.StatusCode = 200;
            js.Message    = "Upload Success";
            try
            {
                T_LMS_Master_AnnualLeave obj = JsonConvert.DeserializeObject <T_LMS_Master_AnnualLeave>(objdata);
                obj = T_LMS_Master_AnnualLeaveManager.Update(obj);
                if (obj.Grade_Id == 0)
                {
                    js.StatusCode = 400;
                    js.Message    = "Has Errors. Please contact Admin for more information";
                }
                else
                {
                    js.Data = obj;
                }
            }
            catch (Exception objEx)
            {
                js.StatusCode = 400;
                js.Message    = objEx.Message;
            }

            return(Content(JsonConvert.SerializeObject(js), "application/json"));
        }
Пример #4
0
        /// <summary>
        /// use for setting up default value
        /// </summary>
        /// <returns></returns>
        public ActionResult Update(int Grade_Id, string TargetID = "T_LMS_Master_AnnualLeavelist")
        {
            T_LMS_Master_AnnualLeave objItem = T_LMS_Master_AnnualLeaveManager.GetById(Grade_Id);

            objItem.TargetDisplayID = TargetID;
            return(View(ViewFolder + "Create.cshtml", objItem));
        }
Пример #5
0
 public static void Delete(T_LMS_Master_AnnualLeave objItem)
 {
     if (objItem != null)
     {
         using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
         {
             HttpResponseMessage response = client.DeleteAsync(string.Format(Resource + "/{0}", objItem.Grade_Id)).GetAwaiter().GetResult();
         }
         RemoveCache(objItem);
     }
 }
Пример #6
0
        public static T_LMS_Master_AnnualLeave Update(T_LMS_Master_AnnualLeave objItem)
        {
            T_LMS_Master_AnnualLeave item = new T_LMS_Master_AnnualLeave();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PutAsJsonAsync(string.Format(Resource + "/{0}", objItem.Grade_Id), objItem).GetAwaiter().GetResult();
                if (response.IsSuccessStatusCode)
                {
                    item = response.Content.ReadAsAsync <T_LMS_Master_AnnualLeave>().GetAwaiter().GetResult();
                    RemoveCache(item);
                }
            }
            return(item);
        }
Пример #7
0
        public static T_LMS_Master_AnnualLeave Add(T_LMS_Master_AnnualLeave objItem)
        {
            T_LMS_Master_AnnualLeave b = new T_LMS_Master_AnnualLeave();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource, objItem).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    b = response.Content.ReadAsAsync <T_LMS_Master_AnnualLeave>().GetAwaiter().GetResult();
                }
            }
            RemoveCache(b);
            return(b);
        }
Пример #8
0
 public ActionResult Update(T_LMS_Master_AnnualLeave model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // TODO: Add insert logic here
             T_LMS_Master_AnnualLeaveManager.Update(model);
             //return RedirectToAction("Index");
         }
         return(View(model));
     }
     catch
     {
         return(View(model));
     }
 }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Grade_Id"></param>
        /// <returns></returns>
        public static T_LMS_Master_AnnualLeave GetById(int Grade_Id)
        {
            string key  = String.Format(SETTINGS_ID_KEY, Grade_Id);
            object obj2 = HttpCache.Get(key);

            if (obj2 != null)
            {
                return((T_LMS_Master_AnnualLeave)obj2);
            }

            T_LMS_Master_AnnualLeave b = new T_LMS_Master_AnnualLeave();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?ID={0}", Grade_Id)).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    b = response.Content.ReadAsAsync <T_LMS_Master_AnnualLeave>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, b);
            return(b);
        }
 // PUT api/<controller>/5
 /// <summary>
 /// Puts the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 /// <exception cref="HttpResponseException"></exception>
 public T_LMS_Master_AnnualLeave Put(string id, [FromBody] T_LMS_Master_AnnualLeave value)
 {
     return(T_LMS_Master_AnnualLeaveManager.UpdateItem(value));
 }
 // POST api/<controller>
 /// <summary>
 /// Posts the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public T_LMS_Master_AnnualLeave Post([FromBody] T_LMS_Master_AnnualLeave value)
 {
     return(T_LMS_Master_AnnualLeaveManager.AddItem(value));
 }
Пример #12
0
        /// <summary>
        /// import data from excel file
        /// </summary>
        /// <param name="objItem"></param>
        /// <returns>return the error Import List</returns>
        public static T_CMS_Master_ContractCollection ImportData(IEnumerable <T_CMS_Master_Contract> objItemList, int EmployeeCode)
        {
            T_COm_Master_Org               objOrg;
            T_COM_Master_Grade             objGrade;
            T_COM_Master_Position          objPosition;
            T_CMS_Master_WorkHours         objWH;
            T_COM_Master_PlaceOfIssue      objPOI;
            T_CMS_Master_EmploymentSubType objEmpSubType;
            int SaluationID = 1;
            T_CMS_Master_ContractCollection ErrorList = new T_CMS_Master_ContractCollection();
            bool   isError  = false;
            string strError = "";
            T_CMS_Master_EmploymentType   objEmpType;
            T_COM_Master_EntityCollection EntityAllows = T_COM_Master_EntityManager.GetAllByEmployeeCode(EmployeeCode);
            string EntityList = "";

            foreach (T_COM_Master_Entity entity in EntityAllows)
            {
                EntityList += entity.EntityId + ";";
            }
            foreach (T_CMS_Master_Contract objitem in objItemList)
            {
                isError  = false;
                strError = "";
                try
                {
                    objPosition = T_COM_Master_PositionManager.GetByName(objitem.PostionName);
                    string[] strPosition = objitem.PostionName.Split('-');
                    if (objPosition.PositionID == 0)
                    {
                        if (strPosition.Length > 0)
                        {
                            objitem.PostionName = strPosition[0];
                        }
                    }
                    string[] strPOI = objitem.IDPOICD.Split('-');
                    if (strPOI.Length > 0)
                    {
                        objitem.IDPOICD = strPOI[0];
                    }
                    objOrg = T_COm_Master_OrgManager.GetByOrgName(objitem.DepartCD);

                    //check permission that you can add to this Entity or not
                    if (EntityList.IndexOf(objOrg.Entity_Id.ToString()) == -1)
                    {
                        strError += "<div>You don't have Permission to Import to this Group: <span class='impval'>" + objitem.DepartCD + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Grade Name:" + objitem.GradeName));
                        isError = true;
                    }

                    objGrade    = T_COM_Master_GradeManager.GetByName(objitem.GradeName);
                    objPosition = T_COM_Master_PositionManager.GetByName(objitem.PostionName);
                    objWH       = T_CMS_Master_WorkHoursManager.GetByWorkHours(objitem.WorkHoursCD);

                    objPOI = T_COM_Master_PlaceOfIssueManager.GetByPOI_Name_VN(objitem.IDPOICD.Trim());

                    if (objGrade.GradeID == 0)
                    {
                        strError += "<div>Invalid Grade Name: <span class='impval'>" + objitem.GradeName + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Grade Name:" + objitem.GradeName));
                        isError = true;
                    }
                    if (objPosition.PositionID == 0)
                    {
                        strError += "<div>Invalid Postion Name: <span class='impval'>" + objitem.PostionName + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Postion Name:" + objitem.PostionName));
                        isError = true;
                    }
                    if (objWH.WorkHoursID == 0)
                    {
                        strError += "<div>Invalid  Work Hours Name: <span class='impval'>" + objitem.WorkHoursCD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Work Hours Name:" + objitem.WorkHoursCD));
                        isError = true;
                    }
                    if (objPOI.POI_ID == 0)
                    {
                        strError += "<div>Invalid  Place of Issues Name: <span class='impval'>" + objitem.IDPOICD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Place of Issues Name:" + objitem.IDPOICD));
                        isError = true;
                    }

                    if (isError)
                    {
                        ErrorList.Add(AddErrorMessage(objitem, strError));
                        continue;
                    }
                    //if we dont have the org get the default value for Org/Department ID
                    if (objOrg.OrgId == 0)
                    {
                        //objOrg.OrgId = 1003; //Default RBVH  1003	RBVH/ETI
                        ErrorList.Add(AddErrorMessage(objitem, "Invalid Department Name:" + objitem.DepartCD));
                        continue;
                    }

                    //get emp subtype by entity and Contract

                    objEmpType = T_CMS_Master_EmploymentTypeManager.GetAllByEntityID(objOrg.Entity_Id, "C");


                    if (objEmpType != null)
                    {
                        objitem.EmpTypeID = objEmpType.EmpTypeID;

                        if (objOrg.Entity_Id != 10001)
                        {
                            objEmpSubType = T_CMS_Master_EmploymentSubTypeManager.GetEmpTypeID(objEmpType.EmpTypeID, objitem.EmpTypeCD);
                            if (objEmpSubType != null)
                            {
                                objitem.EmpSubTypeID = objEmpSubType.EmpSubTypeID;
                            }
                            else
                            {
                                ErrorList.Add(AddErrorMessage(objitem, "Invalid EmployeeSubType Name:" + objitem.EmpTypeCD));
                                continue;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(objitem.POB))
                    {
                        objitem.POB = "";
                    }
                    if (string.IsNullOrEmpty(objitem.HighestDegree))
                    {
                        objitem.HighestDegree = "";
                    }
                    if (string.IsNullOrEmpty(objitem.PerAddress))
                    {
                        objitem.PerAddress = "";
                    }
                    //Location = 6;// objitem.LocationCD.Split('-')[0].Trim();
                    objitem.ID   = 0; //Add new
                    objitem.Mode = "SAVE";
                    //default value
                    objitem.CreatedBy = EmployeeCode;

                    //Grade = int.Parse(objitem.GradeName.Split('-')[1].Trim());

                    objitem.GradeID = objGrade.GradeID;
                    //add annual leave
                    T_LMS_Master_AnnualLeave objAL = T_LMS_Master_AnnualLeaveManager.GetById(objitem.GradeID);
                    if (objAL.Grade_Id != 0)
                    {
                        objitem.AnnualLeave = objAL.NoOfDays;
                    }


                    objitem.PositionID = objPosition.PositionID;
                    if (objitem.SalutationCD.IndexOf("Ms") != -1)
                    {
                        SaluationID = 2;
                    }
                    else if (objitem.SalutationCD.IndexOf("Mrs") != -1)
                    {
                        SaluationID = 3;
                    }
                    else
                    {
                        SaluationID = 1;
                    }



                    objitem.WorkHoursID  = objWH.WorkHoursID;
                    objitem.SalutationID = SaluationID; //DNH fix later
                    objitem.LocationID   = 6;           // int.Parse(Location);
                    objitem.IDPOI        = objPOI.POI_ID;
                    //objitem.HighestDegree
                    objitem.CreatedDate         = SystemConfig.CurrentDate;
                    objitem.PassportDOI         = null;
                    objitem.ModifiedDate        = SystemConfig.CurrentDate;
                    objitem.HostCountryCurrency = "VND";
                    string period      = objitem.ProbationsPeriodCD.Replace("Days", "");
                    int    monthPeriod = 0;
                    if (period == "60")
                    {
                        objitem.ProbationsPeriod = 2;
                        monthPeriod = 2;
                    }
                    else if (period == "30")
                    {
                        objitem.ProbationsPeriod = 1;
                        monthPeriod = 1;
                    }
                    else
                    {
                        objitem.ProbationsPeriod = 0;
                    }
                    objitem.DeptID         = objOrg.OrgId;
                    objitem.LabourDOI      = null;
                    objitem.ModifiedDate   = SystemConfig.CurrentDate;
                    objitem.OriginalDate   = SystemConfig.CurrentDate;
                    objitem.WorkPermitFrom = SystemConfig.CurrentDate;
                    objitem.EmpTypeID      = objEmpType.EmpTypeID; //DNH
                    if (objitem.ContractTermCD.IndexOf("Indefinite") != -1)
                    {
                        if (objOrg.Entity_Id == 10001)
                        {
                            objitem.EmpSubTypeID = 101;//Indefinite Sub-Type
                        }
                        objitem.WorkPermitTo = SystemConfig.EndDate;
                        objitem.Enddate      = SystemConfig.EndDate;
                        objitem.ContractTerm = 0;
                        //check if the the contract have the probation term it will calcuation about enddate --> use for report information
                    }
                    else
                    {
                        if (objOrg.Entity_Id == 10001)
                        {
                            objitem.EmpSubTypeID = 100;  //definite Sub-Type
                        }


                        string[] strContractTerm = objitem.ContractTermCD.Split(' ');


                        if (strContractTerm.Length > 0)
                        {
                            int intTerm = int.Parse(strContractTerm[0]);
                            if (intTerm < 12)
                            {
                                if (objOrg.Entity_Id == 10001)
                                {
                                    objitem.EmpSubTypeID = 103; //seasonable Sub-Type
                                }
                            }

                            objitem.ContractTerm = intTerm;
                            DateTime enddate = objitem.Joiningdate.AddMonths(intTerm);
                            enddate = enddate.AddDays(-1);
                            objitem.WorkPermitTo = enddate;
                            objitem.Enddate      = enddate;
                        }
                    }

                    if (objitem.ProbationsPeriod > 0)
                    {
                        if (monthPeriod == (int)eMonthProbation.ONE_MONTH_PROBATION_PERIOD)
                        {
                            objitem.Enddate = objitem.Joiningdate.AddDays(Constant.ONE_MONTH_PROBATION_PERIOD);
                        }
                        if (monthPeriod == (int)eMonthProbation.TWO_MONTH_PROBATION_PERIOD)
                        {
                            objitem.Enddate = objitem.Joiningdate.AddDays(Constant.TWO_MONTH_PROBATION_PERIOD);
                        }
                    }

                    objitem.HomeGrossOfferEffectiveFrom = SystemConfig.CurrentDate;
                    objitem.HostGrossOfferEffectiveFrom = SystemConfig.CurrentDate;
                    objitem.HomeGrossOfferEffectiveTo   = SystemConfig.CurrentDate;
                    objitem.HostGrossOfferEffectiveTo   = SystemConfig.CurrentDate;


                    objitem.FirstName_EN  = objitem.FirstName_EN.ToUpper();
                    objitem.MiddleName_EN = objitem.MiddleName_EN.ToUpper();
                    objitem.LastName_EN   = objitem.LastName_EN.ToUpper();

                    objitem.FirstName_VN  = objitem.FirstName_VN.ToUpper();
                    objitem.MiddleName_VN = objitem.MiddleName_VN.ToUpper();
                    objitem.LastName_VN   = objitem.LastName_VN.ToUpper();

                    Add(objitem);
                }
                catch (Exception ObjEx)
                {
                    ErrorList.Add(AddErrorMessage(objitem, ObjEx.Message));
                }
            }
            return(ErrorList);
        }
Пример #13
0
        public ActionResult Get(int Grade_Id, string action)
        {
            T_LMS_Master_AnnualLeave objItem = T_LMS_Master_AnnualLeaveManager.GetById(Grade_Id);

            return(Content(JsonConvert.SerializeObject(objItem), "application/json"));
        }
Пример #14
0
        public ActionResult Get(int Grade_Id)
        {
            T_LMS_Master_AnnualLeave objItem = T_LMS_Master_AnnualLeaveManager.GetById(Grade_Id);

            return(View(objItem));
        }