public ApiResult Add([FromBody] ServicePackageModel model)
 {
     db.ServicePackages.Add(new ServicePackage
     {
         Name   = model.Name,
         Price  = model.Price,
         Remark = model.Remark,
     });
     db.SaveChangesAsync();
     return(ApiResult.Ok());
 }
Esempio n. 2
0
        public async Task <ActionResult> Create([Bind(Include = "ID,Name,CategoryID")] SubCategoryMaster subCategoryMaster)
        {
            if (ModelState.IsValid)
            {
                db.SubCategoryMasters.Add(subCategoryMaster);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(subCategoryMaster));
        }
Esempio n. 3
0
        public async Task <ActionResult> Create([Bind(Include = "ID,Name,SupportTeam,LoginID,Password")] EmployeeMaster employeeMaster)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employeeMaster);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(employeeMaster));
        }
Esempio n. 4
0
        public async Task <ActionResult> Create([Bind(Include = "ID,Name")] EmployeeType employeeType)
        {
            if (ModelState.IsValid)
            {
                db.EmployeeTypes.Add(employeeType);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(employeeType));
        }
Esempio n. 5
0
        public async Task <ActionResult> Create([Bind(Include = "ID,EmployeeID,SupportTeam,ClientID,ClientName,CategoryID,Description,Notes,Date,AssignedDate,DeliveryDate,Status")] DailyTask dailyTask)
        {
            if (ModelState.IsValid)
            {
                _db.DailyTasks.Add(dailyTask);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(dailyTask));
        }
Esempio n. 6
0
        public async Task <ActionResult> Create([Bind(Include = "Name,Address,ImagePath")] ImageUploader imageUploader, HttpPostedFileBase file1)
        {
            if (file1 != null && file1.ContentLength > 0)
            {
                // extract only the fielname
                var fileName = Path.GetFileName(file1.FileName);
                // store the file inside ~/App_Data/uploads folder
                var path = Path.Combine(Server.MapPath("~/Images"), fileName);
                file1.SaveAs(path);

                if (ModelState.IsValid)
                {
                    imageUploader.ImagePath = file1.FileName;
                    db.ImageUploaders.Add(imageUploader);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(imageUploader));
        }
Esempio n. 7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Student.ImageName = await SaveImage(Student.ImageFile);

            _db.Students.Add(Student);
            await _db.SaveChangesAsync();

            return(RedirectToPage("./View"));
        }
Esempio n. 8
0
        public async Task <ActionResult> DeleteStudent(int id)
        {
            var student = await _db.Students.FindAsync(id);

            if (student == null)
            {
                return(NotFound());
            }

            _db.Students.Remove(student);
            await _db.SaveChangesAsync();

            return(RedirectToPage("View"));
        }
Esempio n. 9
0
        // Editing student
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var student = _db.Students.Find(Student.Id);

            if (student != null)
            {
                student.FirstName   = Student.FirstName;
                student.LastName    = Student.LastName;
                student.PhoneNumber = Student.PhoneNumber;
                student.ImageName   = Student.ImageName;
                _db.Update(student);


                await _db.SaveChangesAsync();
            }

            return(RedirectToPage("View"));
        }