Esempio n. 1
0
        /// <summary>Lấy dữ liệuMasterDataGroupItem</summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Cat_MasterDataGroupItemModel GetById(Guid id)
        {
            string        status  = string.Empty;
            var           model   = new Cat_MasterDataGroupItemModel();
            ActionService service = new ActionService(UserLogin);
            var           entity  = service.GetByIdUseStore <Cat_MasterDataGroupItemEntity>(id, ConstantSql.hrm_cat_sp_get_MasterDataGroupid, ref status);

            if (entity != null)
            {
                model = entity.CopyData <Cat_MasterDataGroupItemModel>();
            }
            model.ActionStatus = status;
            return(model);
        }
Esempio n. 2
0
        public string Post([Bind] Cat_MasterDataGroupItemModel model)
        {
            #region Validate
            string message       = string.Empty;
            var    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Cat_MasterDataGroupItemModel>(model, "Cat_MasterDataGroupItem", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                // return model;
                return("false");
            }
            #endregion

            #region chuyển string sang list<guid> (MasterDataGroup)
            if (model != null && !string.IsNullOrEmpty(model.ObjectIDStr))
            {
                var  lstObjectIDStr = model.ObjectIDStr.Split(',');
                Guid objectID       = Guid.Empty;
                model.ObjectIDs = new List <Guid?>();
                foreach (var item in lstObjectIDStr)
                {
                    Guid.TryParse(item, out objectID);
                    if (objectID != Guid.Empty)
                    {
                        model.ObjectIDs.Add(objectID);
                    }
                }
            }

            #endregion

            Cat_MasterDataGroupServices catServices = new Cat_MasterDataGroupServices();
            var masterDataGroupItemEntity           = model.CopyData <Cat_MasterDataGroupItemEntity>();
            var result = catServices.AddMasterDataGroupItems(masterDataGroupItemEntity);
            // return result.CopyData<Cat_MasterDataGroupItemModel>();
            return("Success");

            //ActionService service = new ActionService(UserLogin);
            //return service.UpdateOrCreate<Cat_MasterDataGroupItemEntity, Cat_MasterDataGroupItemModel>(model);
        }