public IActionResult GetCreate(PurchasesInfoViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var entity = new HaiKanStudentDiningManagementSystem.Api.MYEntities.Purchases();
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                entity.OrganizationId   = (int)ene.OrganizationId;
                entity.OrganizationName = ene.Name;
                entity.Register         = model.Register;
                entity.RegisterUserId   = model.RegisterUserId;
                entity.RegisterDate     = DateTime.Parse(model.RegisterDate).ToString("yyyy-MM-dd");
                entity.PurchaseUser     = model.PurchaseUser;
                entity.PurchaseDate     = DateTime.Parse(model.PurchaseDate).ToString("yyyy-MM-dd");
                entity.Type             = model.Type;
                entity.Types            = model.Types;
                entity.Supplier         = model.Supplier;
                entity.Status           = "0";
                entity.TicketImgs       = model.TicketImgs;
                entity.Note             = model.Note;
                _dbITMContext.Purchases.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }
Beispiel #2
0
        public IActionResult Create(PesticideViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                var entity = new MYEntities.Pesticides();
                entity.Status         = 1;
                entity.PesticideId    = 0;
                entity.OrganizationId = ene.OrganizationId;
                entity.CreateUserId   = 308343;
                var eneUserName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.UserName && x.OrganizationId == ene.OrganizationId);
                if (eneUserName != null)
                {
                    entity.UserName           = model.UserName;
                    entity.UserOrganizationId = eneUserName.OrganizationId;
                }
                else
                {
                    response.SetFailed("暂无该人员信息");
                    return(Ok(response));
                }
                var eneInspector = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.Inspector && x.OrganizationId == ene.OrganizationId);
                if (eneInspector != null)
                {
                    entity.Inspector = model.Inspector;
                }
                else
                {
                    response.SetFailed("暂无该人员信息");
                    return(Ok(response));
                }
                entity.TestPaper         = model.TestPaper;
                entity.Vegetables        = model.Vegetables;
                entity.VegetablesName    = model.VegetablesName;
                entity.InspectionOrder   = model.InspectionOrder;
                entity.InspectionOrders  = model.InspectionOrders;
                entity.InspectionResult  = model.InspectionResult;
                entity.InspectionResults = model.InspectionResults;
                entity.HandleMeasure     = model.HandleMeasure;
                entity.HandleMeasures    = model.HandleMeasures;
                entity.CheckedAt         = model.CheckedAt;
                entity.CreatedAt         = DateTime.Now;
                entity.Note = model.Note;
                entity.Sync = 0;
                _dbITMContext.Pesticides.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }
Beispiel #3
0
        public IActionResult Create(WasteViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                var entity = new MYEntities.Wastes();
                entity.OrganizationId = ene.OrganizationId;
                if (model.Receiver != "")
                {
                    entity.Status = 1;
                }
                entity.Imgs             = model.Imgs;
                entity.FullName         = model.FullName;
                entity.HandleDate       = model.HandleDate;
                entity.SwillNumber      = model.SwillNumber;
                entity.WasteoilNumber   = model.WasteoilNumber;
                entity.OtherWasteNumber = model.OtherWasteNumber;
                var eneNewHandlerName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.NewHandlerName && x.OrganizationId == ene.OrganizationId);
                if (eneNewHandlerName != null)
                {
                    entity.NewHandlerName = model.NewHandlerName;
                    entity.HandlerId      = eneNewHandlerName.UserId;
                }
                else
                {
                    response.SetFailed("暂无交接负责人信息");
                    return(Ok(response));
                }
                entity.ReceiverCompanyId    = model.ReceiverCompanyId;
                entity.Receiver             = model.Receiver;
                entity.ReceiverCompanyName  = model.ReceiverCompanyName;
                entity.ReceiverIdentityCard = model.ReceiverIdentityCard;
                entity.Note         = model.Note;
                entity.CreateUserId = 308343;
                entity.CreateTime   = DateTime.Now;
                _dbITMContext.Wastes.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }
        public IActionResult Create(SynthesizesViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                var entity = new MYEntities.Synthesizes();
                entity.OrganizationId = ene.OrganizationId;
                entity.Status         = 0;
                entity.Imgs           = model.Imgs;
                entity.SubjectId      = model.SubjectId;
                entity.SubjectName    = model.SubjectName;
                entity.ContinueTime   = model.ContinueTime;
                entity.Department     = model.Department;
                entity.DepartmentName = model.DepartmentName;
                var RepersonName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.Reperson && x.OrganizationId == ene.OrganizationId);
                if (RepersonName != null)
                {
                    entity.Reperson   = model.Reperson;
                    entity.RepersonId = RepersonName.UserId.ToString();
                }
                else
                {
                    response.SetFailed("暂无负责人信息");
                    return(Ok(response));
                }
                entity.Introduce    = model.Introduce;
                entity.Result       = model.Result;
                entity.Number       = model.Number;
                entity.Sync         = 0;
                entity.CreateUserId = model.CreateUserId;
                entity.CreateDate   = model.CreatedAt;
                entity.CreatedAt    = model.CreatedAt;
                _dbITMContext.Synthesizes.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }
Beispiel #5
0
        public IActionResult GetCreate(DisinfectionViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                var entity = new Disinfections();
                entity.OrganizationId = ene.OrganizationId;
                entity.DisinfectionId = 0;
                entity.Sync           = 0;
                //entity.Method = model.Method;
                //entity.Disinfection = model.DxTypeName;         //消毒对象是单个的
                entity.Type                 = model.XdccType;
                entity.TypeName             = model.XdccTypeName;
                entity.CreateUserId         = model.CreateUserId;
                entity.DisinfectionUserId   = model.DisinfectionUserId;
                entity.DisinfectionUserName = model.DisinfectionUserName;
                entity.CreatedDate          = DateTime.Now;
                entity.ImgUrls              = model.ImgUrls;
                entity.Img       = model.Img;
                entity.CreatedAt = DateTime.Now;
                _dbITMContext.Disinfections.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");

                return(Ok(response));
            }
        }
Beispiel #6
0
        public IActionResult Create(MorningCheckViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var org = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                if (org != null)
                {
                    var entity = new Inspections();
                    entity.InspectionId     = 0;
                    entity.OrganizationId   = org.OrganizationId;
                    entity.OrganizationName = org.Name;
                    entity.ShouldCount      = model.ShouldCount.ToString();
                    entity.ActualCount      = "0";
                    entity.UnqualifiedCount = "0";
                    entity.CreatedUser      = 0;
                    entity.Inspector        = model.Inspector;
                    entity.CreatedDate      = DateTime.Now;
                    entity.CreatedAt        = DateTime.Now;
                    entity.IsSupply         = true;
                    entity.Type             = 2;
                    entity.Sync             = 0;
                    entity.IsDifferent      = true;
                    entity.DepartmentId     = model.DepartmentId;
                    //暂无班组选择
                    entity.TeamGroupId = 0;
                    _dbITMContext.Inspections.Add(entity);
                    _dbITMContext.SaveChanges();
                    response.SetSuccess("添加成功");
                }
                else
                {
                    response.SetFailed("不存在该组织");
                }


                return(Ok(response));
            }
        }
Beispiel #7
0
        public IActionResult Create(SamplesViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var ene    = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                var entity = new MYEntities.Samples();
                entity.SampleId       = 0;
                entity.OrganizationId = ene.OrganizationId;
                entity.FoodIds        = model.FoodIds;
                entity.FoodName       = model.FoodName;
                entity.Note           = model.Note;
                entity.Img            = model.Img;
                entity.Weight         = model.Weight;
                entity.Hours          = model.Hours;
                entity.Del            = 1;
                entity.CreateUserId   = 308343;
                entity.MealTime       = model.MealTime;
                entity.MealTimeName   = model.MealTimeName;
                entity.EliminateId    = model.EliminateId;
                entity.EliminateName  = model.EliminateName;
                var eneAuditorName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.AuditorName && x.OrganizationId == ene.OrganizationId);
                if (eneAuditorName != null)
                {
                    entity.AuditorName = model.AuditorName;
                    entity.AuditorId   = Convert.ToInt32(eneAuditorName.UserId);
                }
                else
                {
                    response.SetFailed("暂无该人员信息");
                    return(Ok(response));
                }
                var eneSampleName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.SampleName && x.OrganizationId == ene.OrganizationId);
                if (eneSampleName != null)
                {
                    entity.SampleName   = model.SampleName;
                    entity.SampleUserId = Convert.ToInt32(eneSampleName.UserId);
                }
                else
                {
                    response.SetFailed("暂无该人员信息");
                    return(Ok(response));
                }
                entity.SampledAt    = model.SampledAt;
                entity.CreatedAt    = DateTime.Now;
                entity.MaturedAt    = model.MaturedAt;
                entity.EliminatedAt = model.EliminatedAt;
                entity.Note         = model.Note;
                entity.Sync         = 0;
                _dbITMContext.Samples.Add(entity);
                _dbITMContext.SaveChanges();
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }