// GET api/<controller>/5
        public Can_MealRecordMissingModel Get(Guid id)
        {
            var service = new Can_MealRecordMissingServices();
            var result = service.GetData<Can_MealRecordMissingEntity>(id, ConstantSql.hrm_can_sp_get_MealRecordMissingId,UserLogin, ref status).FirstOrDefault();
            var model = new Can_MealRecordMissingModel
            {
                ID = result.ID,
                ProfileID = result.ProfileID,
                TamScanReasonMissID = result.TamScanReasonMissID,
                WorkDate = result.WorkDate,
                Amount = result.Amount,
                Status = result.Status,
                MealAllowanceTypeSettingID = result.MealAllowanceTypeSettingID,
                IsFullPay = result.IsFullPay,
                Type = result.Type,
                EmpCode = result.EmpCode,
                OrgStructureID = result.OrgStructureID,
                OrgStructureName = result.OrgStructureName,
                TamScanReasonMissName = result.TamScanReasonMissName,
                MealAllowanceTypeSettingName = result.MealAllowanceTypeSettingName
            };

            model.ActionStatus = status;
            return model;
        }
Example #2
0
 public ActionResult Create(Can_MealRecordMissingModel model)
 {
   
     if (ModelState.IsValid)
     {
         var service = new RestServiceClient<Can_MealRecordMissingModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _hrm_Can_Service);
         if (model.MealAllowanceTypeSettingID == Guid.Empty)
             model.MealAllowanceTypeSettingID = null;
         var result = service.Post(_hrm_Can_Service, "api/Can_MealRecordMissing/", model);
         ViewBag.MsgInsert = ConstantDisplay.HRM_Category_Position_CreateSuccess.TranslateString();
     }
     return View();
 }
        public Can_MealRecordMissingModel Post([Bind]Can_MealRecordMissingModel model)
         {

            var mealRecordMissingModel = new Can_MealRecordMissingModel
            {
                ID = model.ID,
                ProfileID = model.ProfileID,
                TamScanReasonMissID = model.TamScanReasonMissID,
                WorkDate = model.WorkDate,
                Amount = model.Amount,
                Status = model.Status,
                MealAllowanceTypeSettingID = model.MealAllowanceTypeSettingID,
                IsFullPay = model.IsFullPay,
                Type= model.Type,
                ActionStatus = model.ActionStatus
            };
            ActionService service = new ActionService(UserLogin);
            if (mealRecordMissingModel.MealAllowanceTypeSettingID != null && mealRecordMissingModel.MealAllowanceTypeSettingID != Guid.Empty)
            {
                string status = string.Empty;
                var mealAllowanceTypeSetting = service.GetByIdUseStore<Can_MealAllowanceTypeSettingEntity>(mealRecordMissingModel.MealAllowanceTypeSettingID.Value,ConstantSql.hrm_can_sp_get_mealallowtypebyid, ref status);
                if (mealAllowanceTypeSetting.Amount!=null)
                    mealRecordMissingModel.Amount = (decimal)mealAllowanceTypeSetting.Amount;
            }
            else if (mealRecordMissingModel.TamScanReasonMissID != null && mealRecordMissingModel.TamScanReasonMissID != Guid.Empty)
            {
                string status = string.Empty;
                var tamScanReasonMiss = service.GetById<Cat_TAMScanReasonMissEntity>(mealRecordMissingModel.TamScanReasonMissID.Value, ref status);
                if (tamScanReasonMiss != null && tamScanReasonMiss.MealAllowanceTypeSettingID != null)
                {
                    var mealAllowanceTypeSetting = service.GetById<Can_MealAllowanceTypeSettingEntity>(tamScanReasonMiss.MealAllowanceTypeSettingID.Value, ref status);
                    mealRecordMissingModel.MealAllowanceTypeSettingID = tamScanReasonMiss.MealAllowanceTypeSettingID;
                    mealRecordMissingModel.Amount =(decimal) mealAllowanceTypeSetting.Amount;
                }
            }
            var data = service.UpdateOrCreate<Can_MealRecordMissingEntity, Can_MealRecordMissingModel>(mealRecordMissingModel);
           
            if (data!=null)
            {

                var dataModel = new Can_MealRecordMissingModel
                {
                    ID = data.ID,
                    ProfileID = data.ProfileID,
                    TamScanReasonMissID = model.TamScanReasonMissID,
                    WorkDate = data.WorkDate,
                    Amount = data.Amount,
                    Status = data.Status,
                    MealAllowanceTypeSettingID = data.MealAllowanceTypeSettingID,
                    IsFullPay = data.IsFullPay,
                    Type = data.Type,
                    EmpCode = data.EmpCode,
                    OrgStructureID = data.OrgStructureID,
                    OrgStructureName = data.OrgStructureName,
                    TamScanReasonMissName = data.TamScanReasonMissName,
                    MealAllowanceTypeSettingName = data.MealAllowanceTypeSettingName,
                    ActionStatus = data.ActionStatus
                };
                return dataModel;
            }
            return null;
        }
Example #4
0
 public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Can_MealRecordMissingModel Can_RecordMissing)
 {
    
     if (ModelState.IsValid)
     {
         var service = new RestServiceClient<Can_MealRecordMissingModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _hrm_Can_Service);
         var result = service.Put(_hrm_Can_Service, "api/Can_MealRecordMissing/", Can_RecordMissing);
         ViewBag.MsgUpdate = ConstantDisplay.HRM_Category_Position_UpdateSuccess.TranslateString();
     }
     return View();
 }