示例#1
0
        public ActionResult DeleteUser(int id)
        {
            try
            {
                using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
                {
                    var user = dbcontext.mblist_user_info.Find(id);

                    if (user != null)
                    {
                        var aspuser = dbcontext.AspNetUsers.Find(user.usr_aspnet_user);
                        dbcontext.mblist_user_info.Remove(user);
                        dbcontext.SaveChanges();
                        if (aspuser != null)
                        {
                            dbcontext.AspNetUsers.Remove(aspuser);
                            dbcontext.SaveChanges();
                        }
                        return(Json(new { key = true, value = "user deleted successfully" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { key = false, value = "user not Found its Deleted from data base!!" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { key = false, value = "Unable to edit the User" }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
 public ActionResult AddOrUpdateEvents(EventDTO dtoEvent)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             DateTime invitationDate = DateTime.ParseExact(dtoEvent.Date, "MM/dd/yyyy h:mm tt", null);
             //Following line is used to get logged in userid
             string usrkey = User.Identity.GetUserId();
             if (dtoEvent.id != 0)
             {
                 var Data = dbcontext.mblist_events_detail.Find(dtoEvent.id);
                 if (Data != null)
                 {
                     Data.event_detail_category_key = dtoEvent.Category;
                     Data.event_detail_type_key     = dtoEvent.EventFor;
                     Data.event_detail_title        = dtoEvent.Title;
                     Data.event_detail_address      = dtoEvent.Address;
                     Data.event_detail_discription  = dtoEvent.Comment;
                     Data.event_detail_date         = invitationDate;
                     Data.event_detail_user_key     = usrkey;
                     dbcontext.SaveChanges();
                     return(Json(new { key = true, value = "event updated successfully", eventKey = Data.event_detail_key }, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     return(Json(new { key = false, value = "event event not found" }, JsonRequestBehavior.AllowGet));
                 }
             }
             else
             {
                 mblist_events_detail evn = new mblist_events_detail()
                 {
                     event_detail_category_key = dtoEvent.Category,
                     event_detail_type_key     = dtoEvent.EventFor,
                     event_detail_title        = dtoEvent.Title,
                     event_detail_address      = dtoEvent.Address,
                     event_detail_date         = invitationDate,
                     event_detail_discription  = dtoEvent.Comment,
                     event_detail_user_key     = usrkey,
                     event_subject_color       = "brown",
                     event_font_color          = "#000",
                     event_subject             = "You are invited for an event"
                 };
                 dbcontext.mblist_events_detail.Add(evn);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "event added successfully", eventKey = evn.event_detail_key }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to save the event" }, JsonRequestBehavior.AllowGet));;
     }
 }
        //insertion
        public ActionResult AddOrUpdateType(TypeDto dto)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
                    {
                        if (dto.id == 0)
                        {
                            var data = dbcontext.mblist_type.Where(x => x.type_name == dto.Type).FirstOrDefault();
                            if (data != null)
                            {
                                return(Json(new { key = false, value = "Type already exist" }, JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                mblist_type type = new mblist_type()
                                {
                                    type_name = dto.Type
                                };

                                dbcontext.mblist_type.Add(type);
                                dbcontext.SaveChanges();
                                return(Json(new { key = true, value = "Type added successfully" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            var data = dbcontext.mblist_type.Find(dto.id);
                            if (data != null)
                            {
                                data.type_name = dto.Type;
                                dbcontext.SaveChanges();
                                return(Json(new { key = true, value = "Type Updated Successfully" }, JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                return(Json(new { key = false, value = "Type is not found" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                    };
                }
                else
                {
                    return(Json(new { key = false, value = "Please enter correct data" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json(new { key = false, value = "Unable to save the Type" }, JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public ActionResult AddOrUpdateAddress(AddressDTO dto)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
                    {
                        if (dto.id == 0)
                        {
                            var data = dbcontext.mblist_address.Where(x => x.address_name == dto.Address).FirstOrDefault();
                            if (data != null)
                            {
                                return(Json(new { key = false, value = "Address already exist" }, JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                mblist_address obj = new mblist_address()
                                {
                                    address_name = dto.Address
                                };
                                dbcontext.mblist_address.Add(obj);
                                dbcontext.SaveChanges();
                                return(Json(new { key = true, value = "Congregation added successfully" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            var data = dbcontext.mblist_address.Find(dto.id);
                            if (data != null)
                            {
                                data.address_name = dto.Address;
                                dbcontext.SaveChanges();
                                return(Json(new { key = true, value = "Address updated successfully" }, JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                return(Json(new { key = false, value = "Address not found" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                    };
                }
                else
                {
                    return(Json(new { key = false, value = "Please enter correct data" }, JsonRequestBehavior.AllowGet));
                }
            }

            catch (Exception)
            {
                return(Json(new { key = false, value = "Unable to save the Address" }, JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult AddOrUpdateCategoreis(CategoriesDTO dto)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
             {
                 if (dto.id == 0)
                 {
                     var data = dbcontext.mblist_service_category.Where(x => x.Category_Name == dto.Category).FirstOrDefault();
                     if (data != null)
                     {
                         return(Json(new { key = false, value = "Group already exist" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         mblist_service_category CATtb = new mblist_service_category()
                         {
                             Category_Name = dto.Category
                         };
                         dbcontext.mblist_service_category.Add(CATtb);
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Category added successfully" }, JsonRequestBehavior.AllowGet));
                     }
                 }
                 else
                 {
                     var data = dbcontext.mblist_service_category.Find(dto.id);
                     if (data != null)
                     {
                         data.Category_Name = dto.Category;
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Category Updated Successfully" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         return(Json(new { key = false, value = "Category is not found" }, JsonRequestBehavior.AllowGet));
                     }
                 }
             };
         }
         else
         {
             return(Json(new { key = false, value = "Please enter correct data" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to save the Category" }, JsonRequestBehavior.AllowGet));;
     }
 }
 public ActionResult AddOrUpdateNeighbourhood(NeighbourhoodDTO dto)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
             {
                 if (dto.id == 0)
                 {
                     var data = dbcontext.mblist_neighborhoods.Where(x => x.neighborhoods_name == dto.Neighbourhood).FirstOrDefault();
                     if (data != null)
                     {
                         return(Json(new { key = false, value = "Neighbourhood already exist" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         mblist_neighborhoods nbhood = new mblist_neighborhoods()
                         {
                             neighborhoods_name = dto.Neighbourhood
                         };
                         dbcontext.mblist_neighborhoods.Add(nbhood);
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Neighbourhood added successfully" }, JsonRequestBehavior.AllowGet));
                     }
                 }
                 else
                 {
                     var data = dbcontext.mblist_neighborhoods.Find(dto.id);
                     if (data != null)
                     {
                         data.neighborhoods_name = dto.Neighbourhood;
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Neighbourhood updated successfully" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         return(Json(new { key = false, value = "Neighbourhood not found" }, JsonRequestBehavior.AllowGet));
                     }
                 }
             };
         }
         else
         {
             return(Json(new { key = false, value = "Please enter correct data" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to save the Neighbourhood" }, JsonRequestBehavior.AllowGet));;
     }
 }
示例#7
0
 public ActionResult AddOrUpdateGroup(GroupDTO dto)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
             {
                 if (dto.id == 0)
                 {
                     var data = dbcontext.mblist_group.Where(x => x.group_name == dto.Group).FirstOrDefault();
                     if (data != null)
                     {
                         return(Json(new { key = false, value = "Group already exist" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         mblist_group group = new mblist_group()
                         {
                             group_name = dto.Group
                         };
                         dbcontext.mblist_group.Add(group);
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Group added successfully" }, JsonRequestBehavior.AllowGet));
                     }
                 }
                 else
                 {
                     var data = dbcontext.mblist_group.Find(dto.id);
                     if (data != null)
                     {
                         data.group_name = dto.Group;
                         dbcontext.SaveChanges();
                         return(Json(new { key = true, value = "Group Updated Successfully" }, JsonRequestBehavior.AllowGet));
                     }
                     else
                     {
                         return(Json(new { key = false, value = "Group is not found" }, JsonRequestBehavior.AllowGet));
                     }
                 }
             };
         }
         else
         {
             return(Json(new { key = false, value = "Please enter correct data" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to save the Group" }, JsonRequestBehavior.AllowGet));;
     }
 }
示例#8
0
 public ActionResult SetTemplateColors(string fontcolor, string subjectcolor, int EventId)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var events = dbcontext.mblist_events_detail.Find(EventId);
             if (events != null)
             {
                 events.event_font_color    = fontcolor;
                 events.event_subject_color = subjectcolor;
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Subject and Font colors updated successfully", templateId = events.event_template_Id }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Event not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception e)
     {
         return(Json(new { key = false, value = "Unable to process your request.Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteInvitation(int Id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var invitation = dbcontext.mblist_invitation_cards.Find(Id);
             if (invitation != null)
             {
                 string path     = invitation.invitation_img_path;
                 string fullPath = Request.MapPath(path);
                 if (System.IO.File.Exists(fullPath))
                 {
                     System.IO.File.Delete(fullPath);
                 }
                 dbcontext.mblist_invitation_cards.Remove(invitation);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Invitation Deleted successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Invitation not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to process your request. Please contact your admin." }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult UploadInvitations()
        {
            if (Request.Files.Count > 0)
            {
                try
                {
                    string dbfile = "";
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFileBase file  = files[i];
                        string             fname = "";
                        dbfile = "";
                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        var myUniqueFileName = Guid.NewGuid().ToString();
                        fname  = myUniqueFileName + "-" + fname;
                        dbfile = fname;
                        if (!Directory.Exists(Server.MapPath("~/Invitations/")))
                        {
                            Directory.CreateDirectory(Server.MapPath("~/Invitations/"));
                        }
                        fname = Path.Combine(Server.MapPath("~/Invitations/"), fname);
                        file.SaveAs(fname);
                        using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
                        {
                            mblist_invitation_cards card = new mblist_invitation_cards()
                            {
                                invitation_img_path = "/Invitations/" + dbfile
                            };
                            dbcontext.mblist_invitation_cards.Add(card);
                            dbcontext.SaveChanges();
                        };
                    }
                    return(Json(new { key = true, value = "Invitation card saved successfully", path = dbfile }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { key = false, value = "Unable to process your request. Please contact your admin." }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { key = false, value = "No file is selected." }, JsonRequestBehavior.AllowGet));
            }
        }
示例#11
0
 public ActionResult AddGuests(List <EventGuests> guests)
 {
     try
     {
         if (guests.Any())
         {
             using (MABRUKLISTEntities dbcontex = new MABRUKLISTEntities())
             {
                 int eventKey  = Convert.ToInt32(guests.FirstOrDefault().EventId);
                 var oldGuests = dbcontex.mblist_event_guests.Where(x => x.guest_event_key == eventKey).ToList();
                 foreach (var g in oldGuests)
                 {
                     dbcontex.mblist_event_guests.Remove(g);
                 }
                 foreach (var guest in guests)
                 {
                     if (guest.userId != null && guest.userId.Trim() != "" && guest.EventId != null && guest.EventId.Trim() != "" && guest.EventId != "0")
                     {
                         mblist_event_guests gst = new mblist_event_guests()
                         {
                             guest_user_key        = guest.userId,
                             guest_event_key       = Convert.ToInt32(guest.EventId),
                             guest_stand_by        = false,
                             guest_invitation_sent = false,
                             guest_reminder_sent   = false,
                         };
                         dbcontex.mblist_event_guests.Add(gst);
                         dbcontex.SaveChanges();
                     }
                 }
             };
             return(Json(new { key = true, value = "Guest Choosed Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { key = false, value = "pleas choose contact" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to choose contact" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#12
0
 public ActionResult SetEventInactive(int Eventkey, bool status)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var eventt = dbcontext.mblist_events_detail.Find(Eventkey);
             if (eventt != null)
             {
                 eventt.event_is_active = status;
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Event Status updated successfully" }, JsonRequestBehavior.AllowGet));
             }
             return(Json(new { key = true, value = "Event not found" }, JsonRequestBehavior.AllowGet));
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to process your request.Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#13
0
 public ActionResult AddOrUpdateRoles(RolesDTO dto)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             Guid        gid  = Guid.NewGuid();
             AspNetRoles rols = new AspNetRoles()
             {
                 Id   = gid.ToString(),
                 Name = dto.Roles
             };
             dbcontext.AspNetRoles.Add(rols);
             dbcontext.SaveChanges();
             return(Json(new { key = true, value = "Roles added successfully" }, JsonRequestBehavior.AllowGet));
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to save the Address" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#14
0
        public ActionResult SetInvitationTemplate(int eventID, int templateKey)
        {
            using (MABRUKLISTEntities dbcontaxt = new MABRUKLISTEntities())
            {
                var template = dbcontaxt.mblist_invitation_cards.Find(templateKey);
                var events   = dbcontaxt.mblist_events_detail.Find(eventID);
                if (events != null)
                {
                    events.event_template_Id = templateKey;
                    ViewBag.background       = template != null ? template.invitation_img_path : string.Empty;
                    ViewBag.EventTitle       = events.event_detail_title;
                    ViewBag.DateTime         = events.event_detail_date;
                    ViewBag.Address          = events.event_detail_address;
                    ViewBag.type             = dbcontaxt.mblist_type.Find(events.event_detail_type_key) != null?dbcontaxt.mblist_type.Find(events.event_detail_type_key).type_name : string.Empty;

                    ViewBag.fontcolor    = events.event_font_color;
                    ViewBag.subject      = events.event_subject;
                    ViewBag.subjectcolor = events.event_subject_color;
                    dbcontaxt.SaveChanges();
                }
            };
            return(PartialView("_InvitationCard"));
        }
示例#15
0
 public ActionResult DeleteRoles(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var rol = dbcontext.AspNetRoles.Find(id);
             if (rol != null)
             {
                 dbcontext.AspNetRoles.Remove(rol);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Roles deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Roles not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to edit the Roles" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#16
0
 public ActionResult DeleteSubtitle(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var Del = dbcontext.mblist_subtitle.Find(id);
             if (Del != null)
             {
                 dbcontext.mblist_subtitle.Remove(Del);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Subtitle deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Subtitle not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the Subtitle" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#17
0
 public ActionResult DeleteGroup(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var Group = dbcontext.mblist_group.Find(id);
             if (Group != null)
             {
                 dbcontext.mblist_group.Remove(Group);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Group deleted successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Group not Found its Deleted from data base!!" }, JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the Group" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteCategory(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var cat = dbcontext.mblist_category.Find(id);
             if (cat != null)
             {
                 dbcontext.mblist_category.Remove(cat);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Category deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Category not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the category" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteType(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var type = dbcontext.mblist_type.Find(id);
             if (type != null)
             {
                 dbcontext.mblist_type.Remove(type);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Type deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Type not Found its Deleted from data base!!" }, JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the Type" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#20
0
 public ActionResult SetStandBy(int guestKey, bool standby)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var guest = dbcontext.mblist_event_guests.Find(guestKey);
             if (guest != null)
             {
                 guest.guest_stand_by = standby;
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Status updated successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Guest not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to process your request.Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteNeighbourhood(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var add = dbcontext.mblist_neighborhoods.Find(id);
             if (add != null)
             {
                 dbcontext.mblist_neighborhoods.Remove(add);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Neighbourhood deleted Successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Neighbourhood not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the Neighbourhood" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#22
0
 public ActionResult UpdateSubject(EventSubjectDTO subject)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var details = dbcontext.mblist_events_detail.Find(subject.EventId);
             if (details != null)
             {
                 details.event_subject = subject.EventSubject;
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Subject updated successfully", eventkey = details.event_detail_key }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Event not found" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception e)
     {
         return(Json(new { key = false, value = "Unable to process your request.Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteCategories(int id)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var ctgry = dbcontext.mblist_service_category.Find(id);
             if (ctgry != null)
             {
                 dbcontext.mblist_service_category.Remove(ctgry);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Category deleted successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Category not Found its Deleted from data base!!" }, JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception)
     {
         return(Json(new { key = false, value = "Unable to edit the Category" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#24
0
 public ActionResult DeleteGuest(int guestKey)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             var guest = dbcontext.mblist_event_guests.Find(guestKey);
             if (guest != null)
             {
                 dbcontext.mblist_event_guests.Remove(guest);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Contact removed successfully" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Contact not found or deleted" }, JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception e)
     {
         return(Json(new { key = false, value = "Unable to process your request.Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#25
0
 public ActionResult AddSubevent(EventDTO sbevntdto)
 {
     try
     {
         using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
         {
             string usrkey = System.Web.HttpContext.Current.User.Identity.GetUserId();
             if (sbevntdto.id != 0)
             {
                 DateTime             date  = DateTime.ParseExact(sbevntdto.Date, "MM/dd/yyyy h:mm tt", null);
                 mblist_events_detail sbven = new mblist_events_detail()
                 {
                     event_detail_user_key     = usrkey,
                     event_parent              = sbevntdto.id,
                     event_detail_category_key = sbevntdto.Category,
                     event_detail_type_key     = sbevntdto.EventFor,
                     event_detail_title        = sbevntdto.Title,
                     event_detail_address      = sbevntdto.Address,
                     event_detail_date         = date,
                     event_detail_discription  = sbevntdto.Comment
                 };
                 dbcontext.mblist_events_detail.Add(sbven);
                 dbcontext.SaveChanges();
                 return(Json(new { key = true, value = "Subevent added successfully", sbevntkey = sbven.event_detail_key }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { key = false, value = "Please create an event" }, JsonRequestBehavior.AllowGet));
             }
         };
     }
     catch (Exception ex)
     {
         return(Json(new { key = false, value = "Unable to process your request. Please contact your admin" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#26
0
        public async Task <ActionResult> AddOrUpdateUser(UserDto userInfo)
        {
            try
            {
                using (MABRUKLISTEntities dbContext = new MABRUKLISTEntities())
                {
                    if (dbContext.AspNetUsers.Any(x => x.Email == userInfo.Email))
                    {
                        return(Json(new { key = false, value = "Email is already assigned to other user" }, JsonRequestBehavior.AllowGet));
                    }
                    if (dbContext.AspNetUsers.Any(x => x.UserName == userInfo.User))
                    {
                        return(Json(new { key = false, value = "Username is already assigned to other user" }, JsonRequestBehavior.AllowGet));
                    }
                };

                var user = new ApplicationUser {
                    UserName = userInfo.User, Email = userInfo.Email, IsEnabled = userInfo.Active
                };
                var result = await UserManager.CreateAsync(user, userInfo.Password);


                if (result.Succeeded)
                {
                    if (userInfo.Role != null)
                    {
                        await this.UserManager.AddToRoleAsync(user.Id, userInfo.Role);
                    }


                    using (MABRUKLISTEntities dbcontext = new MABRUKLISTEntities())
                    {
                        mblist_user_info usrRole = new mblist_user_info()
                        {
                            usr_first_name        = userInfo.FirstName,
                            usr_last_name         = userInfo.LastName,
                            usr_cell_phone        = userInfo.Cellphone,
                            usr_foreign           = userInfo.Foreign,
                            usr_title_key         = userInfo.Title,
                            usr_group_key         = userInfo.Group,
                            usr_sub_title         = userInfo.SubTitle,
                            usr_observation       = userInfo.Observation,
                            usr_neighbourhood_key = userInfo.Neighbourhood,
                            usr_children          = userInfo.Children,
                            usr_sur_name          = userInfo.SingleSurname,
                            usr_apartment         = userInfo.Apartment,
                            usr_blood             = userInfo.Blood,
                            usr_company           = userInfo.Company,
                            usr_phone             = userInfo.Phone,
                            usr_relationship      = userInfo.Relationship,
                            usr_donar             = userInfo.Donor,
                            usr_image_path        = userInfo.Image,
                            usr_aspnet_user       = user.Id,
                        };
                        dbcontext.mblist_user_info.Add(usrRole);
                        dbcontext.SaveChanges();
                        return(Json(new { key = true, value = "User added successfully" }, JsonRequestBehavior.AllowGet));
                    };
                }
                else
                {
                    return(Json(new { key = true, value = "Unable to save user" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { key = false, value = "Unable to save the user" }, JsonRequestBehavior.AllowGet));
            }
        }