Esempio n. 1
0
 public ActionResult RegisterPayment(int ocr_number, int amount)
 {
     if (ModelState.IsValid)
     {
         try
         {
             caretaker caretaker = new caretaker();
             caretaker = operations.FindCaretakerIDThroughOcr(ocr_number);
             if (caretaker.caretaker_id == 0)
             {
                 bool success = false;
                 return(RedirectToAction("RegisterPayment", "Admin", new { success = success }));
             }
             else
             {
                 operations.DecreaseCaretakerDebt(caretaker.caretaker_id, amount);
                 bool success = true;
                 return(RedirectToAction("RegisterPayment", "Admin", new { success = success }));
             }
         }
         catch (Exception)
         {
             string message = "Det går inte att registrera betalningen just nu, vänligen försök igen.";
             return(RedirectToAction("Error", "Home", new { message = message }));
         }
     }
     return(View());
 }
Esempio n. 2
0
 public ActionResult DeleteCaretaker(int?id)
 {
     if (Convert.ToInt32(Session["employe_type"]) == 1 && id != null)
     {
         caretaker caretaker = new caretaker();
         try
         {
             caretaker = operations.FindCaretaker(id);
         }
         catch (Exception)
         {
             string message = "Det går inte att hitta vårdnadshavaren, vänligen försök igen.";
             return(RedirectToAction("Error", "Home", new { message = message }));
         }
         if (caretaker == null)
         {
             return(HttpNotFound());
         }
         return(View(caretaker));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Esempio n. 3
0
        public ActionResult Register(int location_id, string child_name, DateTime birth, string shirtSize, bool CanSwim, bool allowPhoto, bool isVaccinated, string comment, string caretakerName, string caretakerAddress, string caretakerEmail, int caretakerNumber, string altName, int altNumber, int social_security, string allergy_comment)
        {
            long          caretaker_id      = 0;
            long          child_id          = 0;
            List <groups> groups            = new List <groups>();
            DateTime      start_date        = DateTime.Now;
            DateTime      end_date          = DateTime.Now;
            DateTime      registration_date = DateTime.Now;
            location      selectedLocation  = new location();

            if (ModelState.IsValid)
            {
                using (MySqlConnection con = new MySqlConnection(constr))
                {
                    try
                    {
                        int ocr_number = 0;
                        caretaker_id     = operations.SearchForExistingCaretaker(caretakerEmail);
                        selectedLocation = operations.GetLocationInformation(location_id);
                        groups           = operations.GetGroupId(location_id, birth);

                        if (caretaker_id != 0)
                        {
                            operations.UpdateCaretakerDebt(caretaker_id, selectedLocation.price);
                            ocr_number = operations.GetCaretakerOCR(caretaker_id);
                        }
                        if (caretaker_id == 0)
                        {
                            for (int i = 0; i <= 999999; i++)
                            {
                                ocr_number = GenerateOCR();
                                caretaker caretaker = operations.CheckIfOCRIsInUse(ocr_number);
                                if (caretaker.caretaker_id == 0)
                                {
                                    i = 999999;
                                }
                            }
                            caretaker_id = operations.AddCaretaker(caretakerName, caretakerNumber, caretakerEmail, caretakerAddress, altName, altNumber, selectedLocation.price, ocr_number);
                        }
                        child_id = operations.AddChild(child_name, comment, caretaker_id, CanSwim, birth, allowPhoto, isVaccinated, shirtSize, location_id, registration_date, social_security, allergy_comment);
                        operations.AddToGroup(groups, child_id);
                        return(RedirectToAction("OrderConfermation", new { caretakerEmail, caretakerName, child_name, selectedLocation.price, selectedLocation.start_date, selectedLocation.end_date, selectedLocation.location_name, selectedLocation.location_email, selectedLocation.location_number, birth, shirtSize, CanSwim, allowPhoto, isVaccinated, allergy_comment, comment, caretakerAddress, caretakerNumber, altName, altNumber, selectedLocation.weeks, ocr_number }));
                    }
                    catch (Exception)
                    {
                        string message = "Det går inte att registrera barnet, vänligen försök igen.";
                        return(RedirectToAction("Error", "Home", new { message = message }));
                    }
                }
            }
            return(View());
        }
Esempio n. 4
0
 public ActionResult ConfirmedOrder(string caretakerName, string caretakerEmail)
 {
     if (caretakerName == null || caretakerEmail == null)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         caretaker caretakerOrder = new caretaker();
         caretakerOrder.caretaker_name  = caretakerName;
         caretakerOrder.caretaker_email = caretakerEmail;
         return(View(caretakerOrder));
     }
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "caretaker_id,caretaker_name,caretaker_number,caretaker_email,adress,alternative_name,alternative_number,debt")] caretaker caretaker)
 {
     if (ModelState.IsValid)
     {
         try
         {
             operations.UpdateCaretaker(caretaker);
             return(RedirectToAction("Caretaker"));
         }
         catch (Exception)
         {
             string message = "Det går inte att redigera vårdnadshavaren, vänligen försök igen.";
             return(RedirectToAction("Error", "Home", new { message = message }));
         }
     }
     return(View(caretaker));
 }
Esempio n. 6
0
        public ActionResult EditChild(int child_id, int caretaker_id, string name, DateTime birth_date, int social_security, string shirtSize, int group_id, string allergy_comment, string comment, bool can_swim, bool allow_photos, bool vaccinated)
        {
            if (ModelState.IsValid)
            {
                string shirt_size = "";
                if (shirtSize == "0")
                {
                    shirt_size = "80 CL";
                }
                else if (shirtSize == "1")
                {
                    shirt_size = "100 CL";
                }
                else if (shirtSize == "2")
                {
                    shirt_size = "120 CL";
                }
                else if (shirtSize == "3")
                {
                    shirt_size = "140 CL";
                }
                else if (shirtSize == "4")
                {
                    shirt_size = "Small";
                }
                else if (shirtSize == "5")
                {
                    shirt_size = "Medium";
                }
                else if (shirtSize == "6")
                {
                    shirt_size = "Large";
                }
                List <ChildGroupLocationVM> childGroup = new List <ChildGroupLocationVM>();
                List <groups> groups = new List <groups>();
                groups        group  = new groups();
                int           debt   = 300;
                try
                {
                    childGroup = operations.FindChildGroup(child_id);
                    group      = operations.GetGroupInfo(group_id);
                    groups     = operations.GetGroupId(group.location_id, group.birth_year);
                    group_id   = groups[0].group_id;
                    int childGroup_id = childGroup[0].childGroupRelation_id;
                    operations.UpdateChildGroup(group_id, childGroup_id);
                    if (childGroup.Count > 1 && groups.Count > 1)
                    {
                        group_id      = groups[1].group_id;
                        childGroup_id = childGroup[1].childGroupRelation_id;
                        operations.UpdateChildGroup(group_id, childGroup_id);
                    }
                    else if (childGroup.Count == 1 && groups.Count > 1)
                    {
                        long child_ID = child_id;

                        operations.AddToGroup(groups, child_ID);
                        operations.UpdateCaretakerDebt(caretaker_id, debt);
                    }
                    else if (childGroup.Count > 1 && groups.Count == 1)
                    {
                        caretaker caretaker = new caretaker();
                        caretaker     = operations.FindCaretaker(caretaker_id);
                        childGroup_id = childGroup[1].childGroupRelation_id;
                        operations.DeleteFromRelation(childGroup_id);
                        if (caretaker.debt > debt)
                        {
                            operations.DecreaseCaretakerDebt(caretaker_id, debt);
                        }
                    }
                    operations.UpdateChild(child_id, name, allergy_comment, comment, can_swim, birth_date, allow_photos, vaccinated, shirt_size, social_security, group.location_id);


                    return(RedirectToAction("Child"));
                }
                catch (Exception)
                {
                    string message = "Det går inte att redigera barnet, vänligen försök igen.";
                    return(RedirectToAction("Error", "Home", new { message = message }));
                }
            }
            return(RedirectToAction("Child"));
        }