예제 #1
0
        public ActionResult Create(Event tempEvent)
        {
            // by this Linqquery i can access all the data created by the login user
            tempEvent.UserID = objUserBs.GetALL().Where(x => x.Email == User.Identity.Name).FirstOrDefault().UserID;
            objEventBs.Insert(tempEvent);
            // if event is private and there is at least one email
            if (tempEvent.SendInvitationTo != null)
            {
                List <string> emailData = new List <string>();
                var           myList    = tempEvent.SendInvitationTo.Split(',').ToList();
                foreach (string result in myList)
                {
                    if (objUserBs.GetByEmail(result) != null)
                    {
                        emailData.Add(result);
                    }
                }

                //according to the divided email we count the emails and record is save according
                //to the count of email
                foreach (string emailTo in emailData)
                {
                    tempInvitation.EventID = tempEvent.EventID;
                    tempInvitation.Email   = emailTo;
                    objInvitationBs.Insert(tempInvitation);
                }
            }

            try
            {
                if (ModelState.IsValid)
                {
                    //objEventBs.Insert(tempEvent);
                    TempData["Msg"] = "Created Successfully";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.UserID = new SelectList(objUserBs.GetALL().ToList(), "UserID", "Email");
                    return(View("index"));
                }
            }
            catch (DataException dex)
            {
                TempData["Msg"] = "Creation Failed : " + dex.Message;
                return(RedirectToAction("Index"));
            }
        }
예제 #2
0
 public IHttpActionResult Post(User usr)
 {
     if (userObjBs.GetByEmail(ref usr))
     {
         return(Ok(usr));
     }
     else
     {
         foreach (var error in userObjBs.Errors)
         {
             ModelState.AddModelError("", error);
         }
         return(BadRequest(ModelState));
     }
 }