コード例 #1
0
        public ActionResult Create([Bind(Include = "CatId,SubCategoryId,MicrocategoryId,ContactId,Text,NotificationType,NotificationTitle,LocationId,NotificationPhoto,ProvdReqdsuggData,ModuleName,RedirectToType")] RequestNotificationViewModel reqSug)
        {
            if (ModelState.IsValid)
            {
                ContactSuggestion.Models.Source objSource = (ContactSuggestion.Models.Source)Session["UserDetails"];
                //  UserDetails objUserDetails = new UserDetails();
                //string deviceID = string.Empty;
                //string token = string.Empty;
                //string type = string.Empty;
                UserDetails objUserDetails  = new UserDetails();
                DataTable   dtDeviceDetails = new DataTable();
                DataTable   dtlocation      = new DataTable();
                DataTable   dtDeviceUIDList = new DataTable();
                dtDeviceDetails = objUserDetails.GetDeviceDetails(reqSug.ContactId);
                for (int i = 0; i < dtDeviceDetails.Rows.Count; i++)
                {
                    if (string.IsNullOrEmpty(reqSug.NotificationPhoto))
                    {
                        reqSug.NotificationPhoto = "http://tagaboutit.com/Images/phone-display-round-icon.png";
                    }
                    if (reqSug.NotificationType == "Ranking")
                    {
                        reqSug.RedirectTo = "http://tagaboutit.com/login/Ranking";
                    }
                    if (reqSug.NotificationType == "ReqAddSug")
                    {
                        reqSug.RedirectTo = "AddSugg";
                    }
                    if (reqSug.NotificationType == "ProvdReqdsugg")
                    {
                        reqSug.RedirectTo = reqSug.ProvdReqdsuggData;
                    }
                    if (reqSug.NotificationType == "Reqdsuggprovd")
                    {
                        reqSug.RedirectTo = "ViewSugg";
                    }
                    if (reqSug.NotificationType == "MyDetail")
                    {
                        reqSug.RedirectTo = "MyDetail";
                    }
                    if (reqSug.NotificationType == "ModYourSug")
                    {
                        reqSug.RedirectTo = "ViewSugg";
                    }

                    if (Convert.ToInt32(reqSug.RedirectToType) == 1)
                    {
                        reqSug.RedirectTo = reqSug.ModuleName;
                    }
                    if (objUserDetails.SaveNotificationForWebSend(reqSug.UID, reqSug.SubCategoryId, reqSug.MicrocategoryId, reqSug.ContactId, Convert.ToInt32(dtDeviceDetails.Rows[i]["UID"]), reqSug.Text, reqSug.NotificationType, false, reqSug.NotificationTitle, reqSug.LocationId, reqSug.NotificationPhoto, reqSug.RedirectTo, objSource.ContactId, Convert.ToInt32(reqSug.RedirectToType)))
                    {
                        TempData["Success"] = "Added Successfully!";
                        // deviceID = Convert.ToString(dtDeviceDetails.Rows[i]["DeviceID"]);
                        // type = Convert.ToString(dtDeviceDetails.Rows[i]["Type"]);
                        // token = Convert.ToString(dtDeviceDetails.Rows[i]["Token"]);
                        if (reqSug.NotificationType == "ProvdReqdsugg")
                        {
                            dtDeviceDetails = objUserDetails.GetSourcesToken().Tables[0];
                            dtDeviceUIDList = objUserDetails.GetSourcesToken().Tables[1];
                        }
                        else
                        {
                            dtDeviceDetails = objUserDetails.GetSourcesTokenByContactId(reqSug.ContactId).Tables[0];
                            dtDeviceUIDList = objUserDetails.GetSourcesTokenByContactId(reqSug.ContactId).Tables[1];
                        }
                        // string[] strSplit = Convert.ToString(dtDeviceDetails.Rows[0]["TokenList"]).Length > 0 ? Convert.ToString(dtDeviceDetails.Rows[0]["TokenList"]).Split('|') : null;
                        PushAndroidNotification(Convert.ToString(dtDeviceDetails.Rows[0]["TokenList"]), reqSug.CatId, reqSug.SubCategoryId, reqSug.MicrocategoryId, reqSug.LocationId, reqSug.NotificationTitle, reqSug.Text, Convert.ToString(dtDeviceUIDList.Rows[0]["UIDList"]));
                    }
                    else
                    {
                        TempData["Success"] = "Some issue found!";
                    }
                }
                if (dtDeviceDetails.Rows.Count == 0)
                {
                    TempData["Success"] = "No device registered for this contact.";
                }
            }
            RequestNotificationViewModel objRequestNotificationViewModel = new RequestNotificationViewModel();
            DataTable   dtContact             = new DataTable();
            UserDetails objUserDetailsForView = new UserDetails();
            Category    objCategory           = new Category();

            dtContact = objUserDetailsForView.GetCategory(null, null).Tables[0];
            IList <Category> items = dtContact.AsEnumerable().Select(row =>
                                                                     new Category
            {
                CatId         = row.Field <int>("CatId"),
                Name          = row.Field <string>("Name"),
                SubCategories = GetSubCate(row.Field <int>("CatId"))
            }).ToList();

            FillCityDrodown();
            objRequestNotificationViewModel.Categories = items;

            return(View(objRequestNotificationViewModel));
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "UID, SourceId,  ContactId,  Category,  SubCategory,  Microcategory,  BusinessName,  CitiLevelBusiness,  BusinessContact,  Location1,  Comments, IsAChain,  Platform,  CityName,ReasonForChange")] ContactSuggestions contactSugg)
        {
            int locID   = Convert.ToInt32(contactSugg.Location1);
            int?micorID = null;

            if (!string.IsNullOrEmpty(contactSugg.Microcategory))
            {
                micorID = Convert.ToInt32(contactSugg.Microcategory);
            }
            if (ModelState.IsValid)
            {
                string message = string.Empty;
                //  CustomResponseMessage custMessage = new CustomResponseMessage();
                ContactSuggestion.Models.Source objSource = (ContactSuggestion.Models.Source)Session["UserDetails"];
                UserDetails objUserDetails = new UserDetails();
                try
                {
                    DataTable dtDeviceDetails = objUserDetails.GetSourcesTokenByContactId(contactSugg.ContactId).Tables[0];

                    DataTable dtDevices = objUserDetails.GetDeviceDetails(contactSugg.ContactId);

                    //ContactSuggestions objContactSugg = GetContact(contactSugg.contactId);
                    contactSugg.BusinessContact = objUserDetails.MobileFormat(contactSugg.BusinessContact);

                    DataTable dtLocation = objUserDetails.GetLocation(Convert.ToInt32(contactSugg.Location1), string.Empty, string.Empty, Convert.ToInt32(contactSugg.CityName));
                    contactSugg.Location1 = string.IsNullOrEmpty(Convert.ToString(dtLocation.Rows[0]["LocationName"])) ? Convert.ToString(dtLocation.Rows[0]["Suburb"]).Trim() : Convert.ToString(dtLocation.Rows[0]["LocationName"]).Trim() + " - " + Convert.ToString(dtLocation.Rows[0]["Suburb"]).Trim();
                    contactSugg.Location2 = Convert.ToString(dtLocation.Rows[0]["LocationId"]);
                    contactSugg.Location3 = Convert.ToString(dtLocation.Rows[0]["AreaShortCode"]);
                    if (!string.IsNullOrEmpty(contactSugg.BusinessContact))
                    {
                        Int64 isNumber = 0;
                        Int64.TryParse(contactSugg.BusinessContact, out isNumber);
                        if (contactSugg.BusinessContact.Length == 10 && isNumber > 0)
                        {
                            if (objUserDetails.UpdateContactSuggestions(Convert.ToInt32(contactSugg.UID), contactSugg.SourceId, contactSugg.ContactId, contactSugg.Category, contactSugg.SubCategory, contactSugg.Microcategory, contactSugg.BusinessName, contactSugg.CitiLevelBusiness, contactSugg.BusinessContact, contactSugg.Location1, contactSugg.Location2, contactSugg.Location3, contactSugg.Comments, "", "", "", "", contactSugg.ContactComments, contactSugg.IsAChain, contactSugg.Platform, Convert.ToInt32(contactSugg.CityName)))
                            {
                                for (int i = 0; i < dtDevices.Rows.Count; i++)
                                {
                                    objUserDetails.SaveNotificationForWebSend(0, Convert.ToInt32(contactSugg.SubCategory), micorID, contactSugg.ContactId, Convert.ToInt32(dtDevices.Rows[i]["UID"]), contactSugg.ReasonForChange, "ModYourSug", false, "Suggestion Updated", locID, "Suggestion Updated", "ViewSugg", objSource.ContactId, null);
                                }
                                // custMessage.action = "Success";
                                // custMessage.message = "Update Successfully!";
                                TempData["Success"] = "Update Successfully!";

                                PushAndroidNotification(Convert.ToString(dtDeviceDetails.Rows[0]["TokenList"]), Convert.ToInt32(contactSugg.Category), Convert.ToInt32(contactSugg.SubCategory), Convert.ToInt32(contactSugg.Microcategory), Convert.ToInt32(locID), contactSugg.ReasonForChange, "", "", contactSugg.BusinessName, contactSugg.ContactId.ToString(), contactSugg.UID, contactSugg.ReasonForChange);
                            }
                            else
                            {
                                // custMessage.action = "Failure";
                                // custMessage.message = "Please choose different Business Name and Location!.";
                                // return Request.CreateResponse(HttpStatusCode.ExpectationFailed, custMessage);
                                TempData["Success"] = "Please choose different Business Name and Location!";
                            }
                        }
                        else
                        {
                            //// custMessage.action = "Failure";
                            // custMessage.message = "Invalid Business contact number!";
                            //return Request.CreateResponse(HttpStatusCode.ExpectationFailed, custMessage);
                            TempData["Success"] = "Invalid Business contact number!";
                        }
                    }
                    else
                    {
                        if (objUserDetails.UpdateContactSuggestions(Convert.ToInt32(contactSugg.UID), contactSugg.SourceId, contactSugg.ContactId, contactSugg.Category, contactSugg.SubCategory, contactSugg.Microcategory, contactSugg.BusinessName, contactSugg.CitiLevelBusiness, contactSugg.BusinessContact, contactSugg.Location1, contactSugg.Location2, contactSugg.Location3, contactSugg.Comments, "", "", "", "", contactSugg.ContactComments, contactSugg.IsAChain, contactSugg.Platform, Convert.ToInt32(contactSugg.CityName)))
                        {
                            for (int i = 0; i < dtDevices.Rows.Count; i++)
                            {
                                objUserDetails.SaveNotificationForWebSend(0, Convert.ToInt32(contactSugg.SubCategory), micorID, contactSugg.ContactId, Convert.ToInt32(dtDevices.Rows[i]["UID"]), contactSugg.ReasonForChange, "ModYourSug", false, "Suggestion Updated", locID, "Suggestion Updated", "ViewSugg", objSource.ContactId, null);
                            }

                            // custMessage.action = "Success";
                            // custMessage.message = "Update Successfully!";
                            TempData["Success"] = "Update Successfully!";
                            PushAndroidNotification(Convert.ToString(dtDeviceDetails.Rows[0]["TokenList"]), Convert.ToInt32(contactSugg.Category), Convert.ToInt32(contactSugg.SubCategory), Convert.ToInt32(contactSugg.Microcategory), Convert.ToInt32(locID), contactSugg.ReasonForChange, "", "", contactSugg.BusinessName, contactSugg.ContactId.ToString(), contactSugg.UID, contactSugg.ReasonForChange);
                        }
                        else
                        {
                            // custMessage.action = "Failure";
                            // custMessage.message = "Please choose different Business Name and Location!.";
                            // return Request.CreateResponse(HttpStatusCode.ExpectationFailed, custMessage);
                            TempData["Success"] = "Please choose different Business Name and Location!";
                        }
                    }
                }
                catch (Exception ex)
                {
                    TempData["Success"] = ex.Message;

                    // custMessage.action = "Failure";
                    // custMessage.message = ex.Message;
                    //SendEmail(ex.Message, "suggestion PUT");
                    // return Request.CreateResponse(HttpStatusCode.ExpectationFailed, custMessage);
                }
            }
            FillCategoryDrodown(Convert.ToInt32(contactSugg.Category));
            FillSubCateDropdown(Convert.ToInt32(contactSugg.Category), Convert.ToInt32(contactSugg.SubCategory));
            FillMicroCateDropdown(Convert.ToInt32(contactSugg.SubCategory), Convert.ToInt32(contactSugg.Microcategory));
            FillCityDropdown(Convert.ToInt32(contactSugg.CityName));
            FillLocationDropdown(locID, Convert.ToInt32(contactSugg.CityName));
            return(View());
        }