public async Task <ActionResult <Intake> > PostIntake(Intake intake)
        {
            _context.Intakes.Add(intake);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIntake", new { id = intake.Id }, intake));
        }
示例#2
0
    public List <Intake> GetBuffedIntakeList()
    {
        Intake intake = new Intake();

        intake.ammount     = ammount;
        intake.intakeType  = itype;
        intake.intakeClass = iclass;
        intake.origin      = buffManager.gameObject;

        List <Intake> ilist = new List <Intake>();

        ilist.Add(intake);

        int start = 0;
        int len   = 0;

        if (itype == Intake.IntakeType.DAMAGE)
        {
            start = buffManager.GetActivatorFirstElementIndex(BuffManager.Buff.Activator.ON_DMG_DEAL);
            len   = buffManager.GetActivatorLength(BuffManager.Buff.Activator.ON_DMG_DEAL);
        }
        else if (itype == Intake.IntakeType.HEAL)
        {
            start = buffManager.GetActivatorFirstElementIndex(BuffManager.Buff.Activator.ON_HEAL_DEAL);
            len   = buffManager.GetActivatorLength(BuffManager.Buff.Activator.ON_HEAL_DEAL);
        }

        for (int i = start; i < start + len; i++)
        {
            buffManager.buffs[i].Trigger(ilist);
        }

        return(ilist);
    }
        public IActionResult PostNewIntake([FromForm] Intake NewIntake)
        {
            var IntakeInDb = IntakeManager.AddIntake(NewIntake);


            return(Ok(IntakeInDb));
        }
        public async Task <IActionResult> PutIntake(int id, Intake intake)
        {
            if (id != intake.Id)
            {
                return(BadRequest());
            }

            _context.Entry(intake).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IntakeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#5
0
        public async Task <ActionResult <BaseResponse> > PostIntake(Intake intake)
        {
            var datas = _context.Intakes.Where(x => x.IntakeName.Equals(intake.IntakeName.Trim())).ToList();

            if (String.IsNullOrEmpty(intake.IntakeName))
            {
                return(new BaseResponse
                {
                    ErrorCode = 0,
                    Messege = "Not be emty!!"
                });
            }
            else if (datas.Count != 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 2,
                    Messege = "Intake Name already exist!!"
                });
            }
            else
            {
                _context.Intakes.Add(intake);
                await _context.SaveChangesAsync();

                return(new BaseResponse
                {
                    ErrorCode = 1,
                    Messege = "Thêm mới thành công!!",
                    Data = CreatedAtAction("GetIntake", new { id = intake.Id }, intake)
                });
            }
        }
        public async Task <ActionResult <Baserepone> > Post(Intake intakeInput)
        {
            _context.Intakes.Add(intakeInput);
            await _context.SaveChangesAsync();

            return(new Baserepone(intakeInput));
        }
示例#7
0
        public async Task <IActionResult> Edit(int id, [Bind("IntakePk,FeelingWell,Surgeries,Medications,Sensitives,FocusAreas,IsComplete,Fkappointment,Fkclient,Fkstaff")] Intake intake)
        {
            if (id != intake.IntakePk)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(intake);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IntakeExists(intake.IntakePk))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Fkappointment"] = new SelectList(_context.Appointment, "AppointmentPk", "Duration", intake.Fkappointment);
            ViewData["Fkclient"]      = new SelectList(_context.User, "UserPk", "Email", intake.Fkclient);
            ViewData["Fkstaff"]       = new SelectList(_context.User, "UserPk", "Email", intake.Fkstaff);
            return(View(intake));
        }
        public Intake AddIntake(Intake NewIntake)
        {
            var Intake = db.Intakes.FromSqlRaw <Intake>("EXEC  dbo.usp_Intakes_Insert {0},{1}",
                                                        NewIntake.IntakeName, NewIntake.IsActive
                                                        ).ToList().FirstOrDefault();

            return(Intake);
        }
        public Intake EditIntakeById(Intake EditedIntake)
        {
            var Intake = db.Intakes.FromSqlRaw <Intake>("EXEC dbo.usp_Intakes_Update {0},{1}",
                                                        EditedIntake.IntakeId,
                                                        EditedIntake.IntakeName).ToList()
                         .FirstOrDefault();

            return(Intake);
        }
示例#10
0
        public void SetupIntake()
        {
            dgIntake.ShowFooter = true;
            Intake  intake = new Intake();
            DataSet ds     = intake.GetDisplay();

            dgIntake.DataSource = ds.Tables["Intake"];
            dgIntake.DataBind();
        }
示例#11
0
        public void InactivateIntake(Intake intake)
        {
            var hasIntake = _intakeCourseService.GetAll().FirstOrDefault(x => x.IntakeID == intake.IntakeID && x.IsIntakeCourseActive == true);

            if (hasIntake != null)
            {
                throw new DataUsedException("You Cannot remove a Intake That is In Use by a course!");
            }
            _intakeDal.Update(intake);
        }
示例#12
0
        public async Task <ServiceResponse <Intake> > AddNewIntake(Intake intake)
        {
            ServiceResponse <Intake> serviceResponse = new ServiceResponse <Intake>();
            await _db.Intakes.AddAsync(intake);

            await _db.SaveChangesAsync();

            serviceResponse.Data    = intake;
            serviceResponse.Message = "Intake code created successfully";
            return(serviceResponse);
        }
示例#13
0
        // GET: Intake/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Intake intake = db.Intakes.Find(id);

            if (intake == null)
            {
                return(HttpNotFound());
            }
            return(View(intake));
        }
 public async Task <IActionResult> AddNewIntake(Intake intake)
 {
     if (ModelState.IsValid)
     {
         return(Ok(await _intakeService.AddNewIntake(intake)));
     }
     else
     {
         ServiceResponse <Intake> serviceResponse = new ServiceResponse <Intake>();
         serviceResponse.Success = false;
         serviceResponse.Message = "Intake not created";
         return(BadRequest(serviceResponse));
     }
 }
示例#15
0
        public async Task <ActionResult <BaseResponse> > PutIntake(int id, Intake intake_update)
        {
            var Ink = await _context.Intakes.FindAsync(id);

            var datas = _context.Intakes.Where(x => x.IntakeName.Equals(intake_update.IntakeName.Trim())).ToList();

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

            if (intake_update.IntakeName == "")
            {
                return(new BaseResponse
                {
                    ErrorCode = 2,
                    Messege = "Not be emty!!"
                });
            }
            else if (datas.Count != 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 3,
                    Messege = "Intake Name already exist!!"
                });
            }
            else if (Ink.IntakeName == intake_update.IntakeName)
            {
                return(new BaseResponse
                {
                    ErrorCode = 4,
                    Messege = "Intake Name already exist!!"
                });
            }
            else
            {
                Ink.IntakeName = intake_update.IntakeName;

                _context.Intakes.Update(Ink);
                await _context.SaveChangesAsync();

                return(new BaseResponse
                {
                    ErrorCode = 1,
                    Messege = "Update thành công!!"
                });
            }
        }
示例#16
0
        public StatusCodeResult Create([FromBody] Intake intake)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(422));
            }

            if (!_dataAccessProvider.Exists <User>(new ObjectId(intake.UserId), DatabaseConfiguration.UsersEntity))
            {
                return(StatusCode(406));
            }

            _dataAccessProvider.Create(intake, DatabaseConfiguration.IntakeEntity);
            return(StatusCode(201));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Intake = await _context.Intakes.FirstOrDefaultAsync(m => m.Id == id);

            if (Intake == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#18
0
 public ActionResult Delete(int id)
 //DeleteConfirmed(int id)
 {
     try
     {
         Intake intake = db.Intakes.Find(id);
         db.Intakes.Remove(intake);
         db.SaveChanges();
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
     return(RedirectToAction("Index"));
 }
        public async Task <IActionResult> PutIntake(int id, Intake intake_update)
        {
            var Ink = await _context.Intakes.FindAsync(id);

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

            Ink.IntakeName = intake_update.IntakeName;

            _context.Intakes.Update(Ink);
            await _context.SaveChangesAsync();

            return(Ok(Ink));
        }
示例#20
0
        public Intake Insert(Intake entity)
        {
            ValidatorTool.FluentValidate(new IntakeValidator(), entity);
            var hasIntake = GetAll().FirstOrDefault(x => x.IntakeID == entity.IntakeID);

            if (hasIntake != null && hasIntake.IsIntakeActive == false)
            {
                hasIntake.IsIntakeActive = true;
                return(Update(hasIntake));
            }
            else if (hasIntake != null && hasIntake.IsIntakeActive == true)
            {
                throw new DataExistException("This intake is already being used.");
            }

            return(_intakeDal.Insert(entity));
        }
示例#21
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Intake = await _context.Intake.FindAsync(id);

            if (Intake != null)
            {
                _context.Intake.Remove(Intake);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
示例#22
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Intake = await _context.Intake
                     .Include(i => i.FoodEntry).FirstOrDefaultAsync(m => m.ID == id);

            if (Intake == null)
            {
                return(NotFound());
            }
            ViewData["FoodID"] = new SelectList(_context.Set <Food>(), "ID", "Name");
            return(Page());
        }
示例#23
0
        // GET: Intake/Delete/5
        public ActionResult Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator.";
            }
            Intake intake = db.Intakes.Find(id);

            if (intake == null)
            {
                return(HttpNotFound());
            }
            return(View(intake));
        }
示例#24
0
 public ActionResult Create([Bind(Include = "ID,CaseNumber,DeviceModel,CaseAgent,Custodian,WarrantNumber,StorageLocation,IntakeStatus,ReceivedDate,RequestedByDate,IntakeNote")] Intake intake)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Intakes.Add(intake);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException dex)
     {
         Console.WriteLine(dex);
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(intake));
 }
示例#25
0
        public async Task <IActionResult> Create([Bind("FeelingWell,Surgeries,Medications,Sensitives,FocusAreas,IsComplete, Fkappointment,Fkclient,Fkstaff")] Intake intake)
        {
            //if appointment Pk is not valid
            var appointment = _context.Appointment.FirstOrDefault(f => f.AppointmentPk == intake.Fkappointment);

            if (appointment == null)
            {
                return(RedirectToAction("Index", "Appointments"));
            }

            // retrieve user's PK from the Claims collection
            int userPK = Int32.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value);

            intake.Fkclient = userPK;
            intake.Fkstaff  = appointment.Fkstaff;

            try
            {
                _context.Add(intake);
                await _context.SaveChangesAsync();

                //update intake survey foreign key value in appointment table
                var enteredSurvey = await _context.Intake.FirstOrDefaultAsync(surv => surv.Fkappointment == appointment.AppointmentPk);

                appointment.Fkintake = enteredSurvey.IntakePk;
                _context.Update(appointment);
                await _context.SaveChangesAsync();
            }
            catch
            {
                TempData["failure"] = $"Your intake form was not added";
                return(RedirectToAction("Index", "Appointments"));
            }

            //set IsComplete to true
            intake.IsComplete = true;

            TempData["success"] = $"Your intake form was sucessfully added";
            return(RedirectToAction("Index", "Appointments"));

            //return View(intake);
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Intake = await _context.Intakes.FindAsync(id);

            DateTime IntakeDate = DateTime.Now;

            if (Intake != null)
            {
                IntakeDate = Intake.Date;
                _context.Intakes.Remove(Intake);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Dashboard", new { Date = IntakeDate.ToString("yyyy-MM-dd") }));
        }
        public async Task <ActionResult <Baserepone> > Put(int id, Intake intakeInput)
        {
            var intake = await _context.Intakes.FindAsync(id);

            if (intake == null)
            {
                return(new Baserepone
                {
                    errorcode = 1,
                    errormessage = "Not Found Intake Id: " + id
                });
            }
            else
            {
                intake.IntakeName = intakeInput.IntakeName;
                _context.Intakes.Update(intake);
                await _context.SaveChangesAsync();

                return(new Baserepone(intake));
            }
        }
示例#28
0
        public IActionResult Create(int?id)
        {
            //if id is null

            if (id == null)
            {
                return(RedirectToAction("Index", "Appointments"));
            }

            //if appointmentpk is not valid

            var appointment = _context.Appointment.FirstOrDefault(f => f.AppointmentPk == id);

            if (appointment == null)
            {
                return(RedirectToAction("Index", "Appointments"));
            }

            // retrieve user's PK from the Claims collection

            int userPK = Int32.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value);

            // Check if user already has an intake for the appointment

            var anIntake = _context.Intake
                           .FirstOrDefault(i => i.Fkappointment == id && i.Fkclient == userPK);

            // If user has an intake, redirect to My Appointments

            if (anIntake != null)
            {
                return(RedirectToAction("Index", "Appointments"));
            }

            Intake intake = new Intake {
                Fkappointment = appointment.AppointmentPk
            };

            return(View(intake));
        }
示例#29
0
        protected void dgIntake_ItemCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            Intake intake = new Intake();

            if (e.CommandName == "AddIntake")
            {
                TextBox txtTempIntake = (TextBox)e.Item.Cells[1].FindControl("txtMonthNew");

                if (txtTempIntake.Text.Trim() == "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the intake Month!', 'error')</script>'");
                }
                else
                {
                    if (intake.Add(txtTempIntake.Text) == false)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'This intake " + txtTempIntake.Text + " is existed already, try another month', 'error')</script>'");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Added!', text: '" + txtTempIntake.Text + " intake is added successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpIntake.aspx'; }});</script>'");
                    }
                }
            }

            else if (e.CommandName == "DeleteIntake")
            {
                Label rowIntakeID = (Label)e.Item.Cells[0].FindControl("lblID");

                if (intake.DeleteIntake(rowIntakeID.Text) == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Delete intake unsuccessfully', 'error')</script>'");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Deleted!', text: 'Deleted intake successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpIntake.aspx'; }});</script>'");
                }
            }
        }
        public async Task <IActionResult> OnGetAsync(int id)
        {
            //Get active User from session
            ApplicationUser applicationUser;
            string          activeUserId = HttpContext.Session.GetString("activeUserId");

            applicationUser = await _userManager.FindByIdAsync(activeUserId);

            //find intake based on id and the user who created it
            Intake = await _context.Intakes.Where(m => m.User == applicationUser).FirstOrDefaultAsync(m => m.Id == id);

            if (Intake == null)
            {
                return(NotFound());
            }
            else
            {
                Intake.Food = await _context.Foods.FindAsync(Intake.FoodId);

                return(Page());
            }
        }