Exemplo n.º 1
0
        public async Task <IActionResult> putDettaglio(string idStr, int idPre, [FromBody] JObject data)
        {
            string UserID = User.Claims.First(c => c.Type == "UserID").Value;
            Utente user   = await _userManager.FindByIdAsync(UserID);

            var roles = await _userManager.GetRolesAsync(user);

            if (roles.FirstOrDefault() == "UtenteAutorizzato")
            {
                if (!user.AbilitatoAlleNotifiche)
                {
                    return(null);
                }
            }
            var dataFine  = data["DataFine"].ToObject <DateTime>();
            var dettaglio = _context.DettaglioPrenotazione.Where(dp => dp.IdStrumento == idStr && dp.IdPrenotazione == idPre).ToList().FirstOrDefault();

            if (await this.checkPrenotazioniStrumento(idStr, idPre, dettaglio.dataInizio, dataFine))
            {
                dettaglio.dataFine = dataFine;
                _context.DettaglioPrenotazione.Update(dettaglio);
                _context.SaveChanges();
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Exemplo n.º 2
0
        public IActionResult PostFinancialForm([FromBody] PostFinancialFormParam param)
        {
            _logger.LogInformation("post financial form, user:{1}", param.Form.UserName);
            var form = param.Form;

            form.State = FormState.InProcess;
            _context.FinancialForms.Add(form);
            _context.SaveChanges();
            // workflow state should be at securityOk
            // move to financial
            var workflow = _context.WorkFlows.Where(u => u.Id == param.Form.WorkFlowId).Single();

            workflow.State = util.StateRoute[workflow.State].Next[1];
            _logger.LogInformation("rolename: {1}, labid: {2}", util.StateRoute[workflow.State].RoleName, param.Form.LabId);
            var role = _context.Roles
                       .Where(r => r.RoleName == util.StateRoute[workflow.State].RoleName && r.LabId == param.Form.LabId)
                       .Single();
            // send message to role
            var msg = new NotificationMessage
            {
                FormId   = form.Id,
                FormType = FormType.FinancialForm,
                IsSolved = false,
                RoleId   = role.RoleId
            };

            _context.NotificationMessages.Add(msg);
            _context.SaveChanges();
            return(Ok());
        }
        public ActionResult Create(ExamCreateViewModel badanie)
        {
            if (ModelState.IsValid)
            {
                var patient = db.Pacjenci.FirstOrDefault(p => p.PESEL == badanie.PESEL);
                if (patient == null)
                {
                    badanie.IsExistingPesel = false;
                    return(View(badanie));
                }
                var exam = new Exam()
                {
                    Name    = badanie.Name,
                    Patient = patient,
                    Result  = new ExamResult()
                    {
                        Complete = false
                    },
                    Issued = DateTime.Now
                };
                db.Badania.Add(exam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(badanie));
        }
        public IActionResult PostFinancialForm([FromBody] PostFinancialFormParam param)
        {
            var form = param.Form;

            form.State = FormState.InProcess;
            _context.FinancialForms.Add(form);
            // workflow state should be at securityOk
            // move to financial
            var workflow = _context.WorkFlows.Where(u => u.Id == param.Form.WorkFlowId).Single();

            workflow.State = util.StateRoute[workflow.State].Next[1];
            var role = _context.Roles
                       .Where(r => r.RoleName == util.StateRoute[workflow.State].RoleName)
                       .Single();
            // send message to role
            var msg = new NotificationMessage
            {
                FormId   = form.Id,
                FormType = FormType.DeclarationForm,
                IsSolved = false,
                RoleId   = role.RoleId
            };

            _context.NotificationMessages.Add(msg);
            _context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 完成日志记录
        /// </summary>
        /// <param name="professionId"></param>
        /// <param name="newName"></param>
        /// <param name="instituteId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IActionResult Update([Required] Int32 professionId, [Required] String newName, [Required] Int32 instituteId, [Required] ProfessionType type)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.SystemInfoManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        error = "你并无信息管理操作权限"
                    }));
                }
                if (!_context.Institute.Any(ins => ins.InstituteId == instituteId))
                {
                    return(Json(new
                    {
                        isOk = false,
                        error = "不存在此学院!"
                    }));
                }

                Profession pro = _context.Professions.FirstOrDefault(p => p.ProfessionId == professionId);
                if (pro != null)
                {
                    LogPricipalOperation log = _logger.GetDefaultLogPricipalOperation(
                        PrincpalOperationCode.ProfessionUpdate, $"查询编号:{pro.InstituteId}",
                        $"修改专业信息被修改后的专业名{newName} 修改前{pro.Name} 或修改专业类型");

                    log.PrincpalOperationStatus = PrincpalOperationStatus.Success;
                    pro.InstituteId             = instituteId;
                    pro.Name           = newName;
                    pro.ProfessionType = type;
                    _context.LogPricipalOperations.Add(log);
                    _context.SaveChanges();
                    return(Json(new
                    {
                        isOk = true,
                        info = "修改成功!"
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        error = "专业已经不存在,或者已被删除!"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = $"参数错误! 传递了错误的参数!"
                }));
            }
        }
Exemplo n.º 6
0
        public IActionResult DiscardChemical([FromBody] Chemical chemical)
        {
            var c = _context.Chemicals
                    .Where(u => chemical.ChemicalId == u.ChemicalId)
                    .Single();

            c.State = ChemicalState.Obsoleted;
            _context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 7
0
        public IActionResult AddJudge(string judgeName)
        {
            LPR newJudge = new LPR();

            newJudge.LName  = judgeName;
            newJudge.LRange = 1;
            db.LPRs.Add(newJudge);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Teachers_id,Teachers_name,Teachers_age,Teachers_level,Teachers_phone,Kafedra_id")] Teachers teachers)
        {
            if (ModelState.IsValid)
            {
                db.Teacher.Add(teachers);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(teachers));
        }
        public ActionResult Create([Bind(Include = "LTNumber,CustomerID,CompoundName,MillQuant,Active,Comments,QuantitativeFileType,QualitativeResults,QuantitativeResults,MTD")] Compound compound)
        {
            if (ModelState.IsValid)
            {
                db.Compounds.Add(compound);
                db.SaveChanges();
                return(RedirectToAction("Create", "WorkOrders", new { area = "" }));
            }

            return(View(compound));
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "Instytyts_id,Instytyts_name,Director")] Instutyt instutyt)
        {
            if (ModelState.IsValid)
            {
                db.Instutyts.Add(instutyt);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(instutyt));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Kafedra_id,Kafedra_name,Kafedra_zav,Count_Doctor_Science,Instytyts_id")] Kafedra kafedra)
        {
            if (ModelState.IsValid)
            {
                db.Kafedras.Add(kafedra);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kafedra));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Subject_id,Subject_name,Subject_hour,Subject_Type_Ex")] Subjects subjects)
        {
            if (ModelState.IsValid)
            {
                db.Subject.Add(subjects);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subjects));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,Address,City,State,Zip,Email,Password,Phone,AdvanceMoney")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            return(View(customer));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "CityId,CityName,Population,ProvinceId")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProvinceId = new SelectList(db.Provinces, "ProvinceId", "ProvinceName", city.ProvinceId);
            return(View(city));
        }
        public ActionResult Create([Bind(Include = "AssayID,TypeCode,SummaryInfo,DetailedInfo,Procedure,LiteratureReferences,EstimateDaysToComplete")] Assay assay)
        {
            ViewBag.TypeCode = db.AssayTypes.ToList();
            if (ModelState.IsValid)
            {
                db.Assays.Add(assay);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assay));
        }
Exemplo n.º 16
0
        //根据id减少信誉积分
        public bool Fine(long id)
        {
            var state   = false;
            var student = Context.Reader.SingleOrDefault(s => s.reader_id == id);

            if (student != null)
            {
                student.credit -= 10;
                state           = Context.SaveChanges() > 0;
            }
            return(state);
        }
Exemplo n.º 17
0
        public ActionResult CreateOrder([Bind(Include = "Order_ID, Cust_ID, Date_Created, Expedite_Order, Test2_IfActive, Test2_IfInactive, Analysis_Completed")] WorkOrders wo)
        {
            if (ModelState.IsValid)
            {
                //add entry
                db.WorkOrders.Add(wo);
                //edit entries
                //db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("MyOrders"));
            }

            return(View(wo));
        }
Exemplo n.º 18
0
        public ActionResult CreateTest([Bind(Include = "Test_ID, Test_Description, Test_Details, Test_Price")] Tests tests)
        {
            if (ModelState.IsValid)
            {
                //add entry
                db.Tests.Add(tests);
                //edit entries
                //db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("WorkOrders"));
            }

            return(View(tests));
        }
 public ActionResult Edit(
     [Bind(
          Include =
              "Id,Email,PhoneNumber,UserName"
          )] ApplicationUser applicationUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(applicationUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(applicationUser));
 }
Exemplo n.º 20
0
        public ActionResult CreateCustomer([Bind(Include = "Cust_ID, Cust_First_Name, Cust_Last_Name, Cust_Address, Cust_City, Cust_State, Cust_Country, Cust_Zip, Cust_Email, Cust_Password, Cust_Phone, Account_Created_Date, Cust_Discount")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                //add entry
                db.Customers.Add(customer);
                //edit entries
                //db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(customer);
        }
        public ActionResult Create([Bind(Include = "LT_Number, Assay_ID, Order_ID, Date_Arrived, Date_Processed, Date_Due, Compound_Weight_Client, Actual_Weight, Molecular_Mass")] Compound_Samples cs)
        {
            if (ModelState.IsValid)
            {
                //add entry
                db.Compound_Samples.Add(cs);
                //edit entries
                //db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("CreateOrderDetail"));
            }

            ViewBag.Message = "Error in validation";
            return(View(cs));
        }
        public ActionResult Create([Bind(Include = "OrderID,LTNumber,CustomerID,OrderTotal,DateArrived,ReceivedBy,DueDate,Quote,Discount,CurrentCost,ConfirmationSentDate,SummaryReport")] WorkOrder workOrder)
        {
            if (ModelState.IsValid)
            {
                Random r = new Random();
                var    x = r.Next(0, 1000000);

                workOrder.LTNumber = x;
                db.WorkOrders.Add(workOrder);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workOrder));
        }
Exemplo n.º 23
0
        public bool AddUserSuggestion(UserSuggestion suggestion)
        {
            db.UserSuggestions.Add(suggestion);
            Boolean result = (db.SaveChanges() == 1);

            return(result);
        }
Exemplo n.º 24
0
        public async Task <ActionResult> PostPrenotazione()
        {
            Prenotazione prenotazione = new Prenotazione();

            _context.Prenotazione.Add(prenotazione);
            _context.SaveChanges();
            var user = await _userManager.FindByIdAsync(User.Claims.First(c => c.Type == "UserID").Value);

            prenotazione.Utente = user;
            ICollection <DettaglioPrenotazione> strumenti = SessionHelper.GetObjectFromJson <ICollection <DettaglioPrenotazione> >(HttpContext.Session, "cart");

            if (strumenti.Count == 0)
            {
                return(BadRequest());
            }
            foreach (var d in strumenti)
            {
                var s = _context.Strumento.Find(d.IdStrumento);
                d.IdPrenotazione = prenotazione.ID;
                d.Prenotazione   = prenotazione;
                d.Strumento      = s;
                _context.DettaglioPrenotazione.Add(d);
                await _context.SaveChangesAsync();
            }
            prenotazione.Strumenti = strumenti;


            await _context.SaveChangesAsync();

            SessionHelper.Reset(HttpContext.Session, "cart");

            return(Ok());
        }
Exemplo n.º 25
0
        public MainWindow()
        {
            InitializeComponent();
            using (LabContext db = new LabContext())
            {
                unitOfWork.CompaniesUnits.ListOfCompanies = db.Companies.ToList();
                unitOfWork.EmployeesUnits.ListOfEmployees = db.Employees.ToList();
                db.SaveChanges();
            }


            //var company1 = new Company { Name = "Mila", Cost = 50000000, Adress = "Минск, Бобруйская 6" };
            //var company2 = new Company { Name = "Electrosila", Cost = 150000000, Adress = "Минск, Бобруйская 6" };

            //using (CompaniesContext db = new CompaniesContext())
            //{
            //    db.Companies.Add(company1);
            //    db.Companies.Add(company2);
            //    db.SaveChanges();
            //}

            //using (EmployeesContext db = new EmployeesContext())
            //{
            //    var employee1 = new Employee { Id = 1, Name = "Nikolai", Age = 24, Post = "Consultant", Wage = 400, CompanyName = company1.Name };
            //    var employee2 = new Employee { Id = 2, Name = "Olga", Age = 22, Post = "Salesman", Wage = 500, CompanyName = company1.Name };

            //    db.Employees.Add(employee1);
            //    db.Employees.Add(employee2);
            //    db.SaveChanges();
            //}
        }
Exemplo n.º 26
0
        public JsonResult SaveEvents(Event e)
        {
            var status = false;

            using (LabContext db = new LabContext())
            {
                if (e.EventID > 0)
                {
                    // Update the event
                    var v = db.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.ThemeColor  = e.ThemeColor;
                        v.IsFullDay   = e.IsFullDay;
                    }
                }
                else
                {
                    db.Events.Add(e);
                }
                db.SaveChanges();
                status = true;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemplo n.º 27
0
        public IActionResult PostClaimForm([FromBody] PostClaimFormParam param)
        {
            _logger.LogInformation("Get posted claim form. formid: {formid}", param.Form.Id);
            var form = param.Form;

            form.State = Utils.FormState.InProcess;
            _context.ClaimForms.Add(form);
            _context.SaveChanges();
            // data format
            foreach (var chemical in param.Chemicals)
            {
                var entity = new ClaimFormChemical
                {
                    ChemicalId  = chemical.ChemicalId,
                    ClaimForm   = form,
                    ClaimFormId = form.Id
                };
                _context.ClaimFormChemicalMap.Add(entity);
                var dbChemical = _context.Chemicals.Where(c => c.ChemicalId == chemical.ChemicalId).Single();
                dbChemical.State = ChemicalState.InApplication;
            }
            var roles = _context.Roles
                        .Where(r => r.RoleName == "LabTeacher" && r.LabId.HasValue? r.LabId == form.LabId:false)
                        .ToList();

            _logger.LogInformation("Send message to {0} roles.", roles.Count);
            _logger.LogInformation("Role list: ");
            foreach (var role in roles)
            {
                _logger.LogInformation("Role id: {0}, name: {1}", role.RoleId, role.RoleName);
                // send message to role
                var msg = new NotificationMessage
                {
                    FormId   = form.Id,
                    FormType = FormType.ClaimForm,
                    IsSolved = false,
                    RoleId   = role.RoleId
                };
                _context.NotificationMessages.Add(msg);
            }
            _context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 28
0
        public void FinishPaper(ExaminationPaper paper, LabContext context)
        {
            if (paper != null)
            {
                if (!paper.IsFinish)
                {
                    if (paper.LeaveExamTime <= 1.0)
                    {
                        paper.LeaveExamTime = 0;
                    }

                    paper.IsFinish = true;

                    if (String.IsNullOrEmpty(paper.Review))
                    {
                        paper.Review = "学生未作出评价!";
                    }
                    paper.Score = GetPaperScore(paper.PaperId, context);

                    Student student = context.Student.Find(paper.StudentId);


                    if (student != null)
                    {
                        if (paper.Score >= paper.PassScore)
                        {
                            student.IsPassExam = true;
                        }

                        double middle = Math.Round((paper.Score / paper.TotleScore) * 100, 1);

                        if (middle > student.MaxExamCount)
                        {
                            student.MaxExamScore = (float)middle;
                        }
                    }
                    else
                    {
                        context.LogPricipalOperations.Add(new LogPricipalOperation
                        {
                            PrincpalOperationStatus = PrincpalOperationStatus.Success,
                            AddTime = DateTime.Now,
                            PrincpalOperationCode    = PrincpalOperationCode.SystemRuntimeError,
                            OperationIp              = "系统运行产生!",
                            PrincpalOperationName    = $"试卷ID:{paper.PaperId} ,试卷所属学生学号:{paper.StudentId}",
                            PrincpalOperationContent = "完成试卷的时候发现学生已经被删除! 考试期间管理员删除了学生导致考试异常! 请查看."
                        });
                    }


                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 29
0
        public IActionResult PostDeclarationForm([FromBody] PostDeclarationFormParam param)
        {
            var form = param.Form;

            form.State = FormState.InProcess;
            // first create a workflow
            var workflow = new WorkFlow
            {
                UserId      = param.Form.UserId,
                StartTime   = DateTime.Now,
                State       = "declearing",
                Chemicals   = param.Chemicals,
                Description = param.Form.Reason,
                UserName    = param.Form.UserName
            };

            _context.WorkFlows.Add(workflow);
            _context.SaveChanges();
            // create form_workflow_relationship
            form.WorkFlowId = workflow.Id;
            _context.DeclarationForms.Add(form);
            _context.SaveChanges();
            var role = GetNotifyRoleId(util.StateRoute[workflow.State].RoleName, param.Form.LabId);
            // send message to role
            var msg = new NotificationMessage
            {
                FormId   = form.Id,
                FormType = FormType.DeclarationForm,
                IsSolved = false,
                RoleId   = role
            };

            _context.NotificationMessages.Add(msg);
            _context.SaveChanges();
            return(Ok());
        }
        public ActionResult Create(PatientCreateViewModel patientData)
        {
            if (ModelState.IsValid)
            {
                var dbPatient = db.Pacjenci.FirstOrDefault(p => p.PESEL == patientData.PESEL.Trim());
                if (dbPatient != null)
                {
                    patientData.AlreadyExists = true;
                    patientData.ActualPatient = dbPatient;
                    return(View(patientData));
                }
                var newPatient = new Patient()
                {
                    LastName = patientData.LastName,
                    Name     = patientData.Name,
                    PESEL    = patientData.PESEL
                };
                db.Pacjenci.Add(newPatient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(patientData));
        }