Ejemplo n.º 1
0
        public IActionResult Delete([Required] String sId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "你并无学生管理操作权限"
                    }));
                }
                Student stu = _context.Student.Find(sId);
                if (stu != null)
                {
                    LogPricipalOperation log = _logger.GetDefaultLogPricipalOperation(
                        PrincpalOperationCode.DeleteStudent, $"查询编码:{stu.StudentId}", $"删除学生{stu.Name}");
                    List <ApplicationForReExamination> apps = _context.ApplicationForReExaminations
                                                              .Where(app => app.StudentId == sId).ToList();
                    if (apps.Count > 0)
                    {
                        _context.ApplicationForReExaminations.RemoveRange(apps);
                    }

                    log.PrincpalOperationStatus = PrincpalOperationStatus.Success;
                    _context.Add(log);
                    _context.Student.Remove(stu);
                    _context.SaveChanges();
                    return(Json(new
                    {
                        isOk = true,
                        title = "提示信息",
                        message = "删除成功!!"
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "学生不存在或者已经被删除了!"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    title = "错误信息",
                    message = "传入的参数错误"
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Phone,Address")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Site")] Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                _context.Add(delivery);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(delivery));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,StreetAddress,ZipCode,City,Country,Ssn,PhoneNumber1,PhoneNumber2,Email")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(IndexSearch)));
            }
            return(View(person));
        }
        public async Task <IActionResult> Create([Bind("Id,ProductId,TagId")] ProductTag productTag)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productTag);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Description", productTag.ProductId);
            ViewData["TagId"]     = new SelectList(_context.Tags, "Id", "Name", productTag.TagId);
            return(View(productTag));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,ProductId,CustomerId,DeliveryId,Time")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Address", order.CustomerId);
            ViewData["DeliveryId"] = new SelectList(_context.Deliveries, "Id", "Name", order.DeliveryId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "Description", order.ProductId);
            return(View(order));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 创建一个新的学院
        /// </summary>
        /// <param name="name"></param>
        /// <param name="moduleId"></param>
        /// <returns></returns>
        public async Task <IActionResult> Create([Required] String name, [Required] int moduleId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.SystemInfoManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        error = "你并无信息管理操作权限"
                    }));
                }

                if (_context.Modules.Any(m => m.ModuleId == moduleId))
                {
                    if (_context.Institute.Any(ins => ins.Name == name))
                    {
                        return(Json(new
                        {
                            isOk = false,
                            error = "新建学院名称重复,已经存在此学院"
                        }));
                    }
                    else
                    {
                        LogPricipalOperation log =
                            _logger.GetDefaultLogPricipalOperation(
                                PrincpalOperationCode.InstituteAdd,
                                $"添加新的学院",
                                $"添加新的学院名称 {name}");

                        log.PrincpalOperationStatus = PrincpalOperationStatus.Success;
                        _context.LogPricipalOperations.Add(log);
                        Institute institute = new Institute {
                            Name = name
                        };
                        _context.Institute.Add(institute);
                        await _context.SaveChangesAsync().ContinueWith(t =>
                        {
                            int result = t.Result;
                            if (result == 1)
                            {
                                InstituteToModule instituteToModule = new InstituteToModule();
                                instituteToModule.ModuleId          = moduleId;
                                instituteToModule.InstituteId       = institute.InstituteId;
                                _context.Add(instituteToModule);
                                _context.SaveChangesAsync();
                            }
                        });

                        return(Json(new
                        {
                            isOk = true,
                        }));
                    }
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        error = "不存在此模块!学院不可属于此模块"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = "参数错误"
                }));
            }
        }