public void MassCreateDeparmentTypes()
        {
            var fakeDeparmentTypes = new List <DeparmentTypeViewModel>();

            for (int i = 1; i < 6; i++)
            {
                var deparmentType = new DeparmentTypeViewModel()
                {
                    DeparmentTypeCode        = $"DTCODE{i}",
                    DeparmentTypeName        = $"DeparmentTypeName {i}",
                    DeparmentTypeDescription = $"DeparmentTypeDesription {i}",
                    Status = true
                };
                fakeDeparmentTypes.Add(deparmentType);
            }

            foreach (var deparmentTypeViewModel in fakeDeparmentTypes)
            {
                DeparmentType newDeparmentType = new DeparmentType();
                newDeparmentType.UpdateDeparmentType(deparmentTypeViewModel);

                _deparmentTypeService.Add(newDeparmentType);
                _deparmentTypeService.Save();
            }
        }
 public DeparmentType Add(DeparmentType deparmentType)
 {
     deparmentType.CreatedDate = DateTime.Now;
     //deparmentType.CreatedBy = ad //Todo: Add CreatedBy
     deparmentType.UpdatedDate = DateTime.Now;
     //deparmentType.UpdatedBy = ad //Todo: Add CreatedBy
     return(_deparmentTypeRepository.Add(deparmentType));
 }
Example #3
0
        public static void UpdateDeparmentType(this DeparmentType computerType, DeparmentTypeViewModel computerTypeVm)
        {
            computerType.DeparmentTypeId          = computerTypeVm.DeparmentTypeId;
            computerType.DeparmentTypeCode        = computerTypeVm.DeparmentTypeCode;
            computerType.DeparmentTypeName        = computerTypeVm.DeparmentTypeName;
            computerType.DeparmentTypeDescription = computerTypeVm.DeparmentTypeDescription;

            computerType.CreatedDate     = computerTypeVm.CreatedDate;
            computerType.CreatedBy       = computerTypeVm.CreatedBy;
            computerType.UpdatedDate     = computerTypeVm.UpdatedDate;
            computerType.UpdatedBy       = computerTypeVm.UpdatedBy;
            computerType.MetaKeyword     = computerTypeVm.MetaKeyword;
            computerType.MetaDescription = computerTypeVm.MetaDescription;
            computerType.Status          = computerTypeVm.Status;
        }
Example #4
0
        /// <summary>
        /// 取上级科室ID
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string GetParentId(string id, DeparmentType type)
        {
            string sql;

            if (type == DeparmentType.一级科室)
            {
                return(null);
            }
            if (type == DeparmentType.二级科室)
            {
                sql = "select ParentID from KS_DepartmentNode where id='" + id + "'";
            }
            else
            {
                sql = "select ParentId as  ParentID from KS_DepartmentLeaf where id='" + id + "'";
            }
            return(FrmMdiMain.Database.GetDataTable(sql).Rows[0]["ParentID"].ToString());
        }
Example #5
0
        public HttpResponseMessage Post(HttpRequestMessage request, DeparmentTypeViewModel deparmentTypeVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.Values.FirstOrDefault()?.Errors.FirstOrDefault()?.ErrorMessage);
                }
                else
                {
                    var newDeparmentType = new DeparmentType();
                    newDeparmentType.UpdateDeparmentType(deparmentTypeVm);

                    var deparmentType = _deparmentTypeService.Add(newDeparmentType);
                    _deparmentTypeService.Save();

                    response = request.CreateResponse(HttpStatusCode.Created, deparmentType);
                }
                return response;
            }));
        }
 public void Update(DeparmentType deparmentType)
 {
     deparmentType.UpdatedDate = DateTime.Now;
     //deparmentType.UpdatedBy = ad //Todo: Add CreatedBy
     _deparmentTypeRepository.Update(deparmentType);
 }