public DataReturn UpdateCustomermessegingData(RCSMessegeClass obj)
        {
            DataReturn model = new DataReturn();

            try
            {
                CustomerContactMesseging cust = db.CustomerContactMesseging.Find(obj.mainObj.PKey);

                cust.AddedOn      = obj.mainObj.AddedOn;
                cust.Comment      = obj.mainObj.Comment;
                cust.IsMessegeNew = true;
                cust.Remarks      = "Updated on " + System.DateTime.Now.ToString() + " by " + GlobalClass.LoginUser.Cname;

                db.SaveChanges();

                model.flag = 1;
                model.mess = "Data has been saved successfully.";
                model.key  = cust.PKey;
            }
            catch (Exception ex)
            {
                model.flag = 0;
                model.mess = ex.Message.ToString();
            }
            return(model);
        }
        public RCSMessegeClass LoadCustomerMessegingData(Guid id)
        {
            RCSMessegeClass model = new RCSMessegeClass();

            model.Messege        = new DataReturn();
            model.Messege.mess   = "customer communication Details";
            model.Messege.flag   = 1;
            model.mainObj        = new RCSMessegeMain();
            model.mainObj.JobKey = id;
            model.Job            = db.Job.Find(id);
            model.VendorKey      = model.Job.CustomerKey;
            model.mailList       = new List <RCSMessegeMain>();
            try
            {
                var temp = (from x in db.CustomerMesseging
                            where x.JobKey == id && x.IsDelete == false
                            select new RCSMessegeMain
                {
                    PKey = x.PKey,
                    JobKey = x.JobKey,
                    AddedBy = x.AddedBy,
                    AddedOn = x.AddedOn,
                    Comment = x.Comment,
                    Title = x.Title,
                    Designation = x.StaffList.Designation,
                    Staffname = x.StaffList.PName,
                    VendorKey = x.CustomerKey,
                    vendorName = x.Customer.Cname,
                    IsAdmin = true
                }).OrderByDescending(m => m.AddedOn).ToList();
                model.mailList = temp;
                var tempContact = from x in db.CustomerContactMesseging where x.JobKey == id && x.IsDelete == false select x;
                if (tempContact.Count() > 0)
                {
                    foreach (var item in tempContact)
                    {
                        RCSMessegeMain obj = new RCSMessegeMain();
                        obj.PKey        = item.PKey;
                        obj.JobKey      = item.JobKey;
                        obj.AddedBy     = item.AddedBy;
                        obj.AddedOn     = item.AddedOn;
                        obj.Comment     = item.Comment.Count() > 50 ? item.Comment.Substring(0, 50) + "...." : item.Comment;
                        obj.Title       = item.Title;
                        obj.Designation = item.CustomerContact.Title;
                        obj.Staffname   = item.CustomerContact.Cname;
                        obj.VendorKey   = item.CustomerKey;
                        obj.vendorName  = item.Customer.Cname;
                        obj.IsAdmin     = false;
                        model.mailList.Add(obj);
                    }
                }
            }
            catch (Exception ex)
            {
                model.Messege.mess = ex.Message.ToString();
                model.Messege.flag = 0;
            }
            model.mailList.OrderByDescending(m => m.AddedOn);
            return(model);
        }
        public DataReturn SaveCustomermessegingData(RCSMessegeClass obj)
        {
            DataReturn model = new DataReturn();

            try
            {
                CustomerContactMesseging cust = new CustomerContactMesseging();
                cust.PKey = Guid.NewGuid();

                cust.JobKey       = obj.mainObj.JobKey;
                cust.AddedBy      = GlobalClass.LoginUser.ContactKey;
                cust.AddedOn      = obj.mainObj.AddedOn;
                cust.Comment      = obj.mainObj.Comment;
                cust.Title        = "Update for Job: " + obj.Job.JobName;
                cust.IsDelete     = false;
                cust.Remarks      = "";
                cust.CustomerKey  = obj.VendorKey;
                cust.IsMessegeNew = true;

                db.CustomerContactMesseging.Add(cust);
                db.SaveChanges();

                model.flag = 1;
                model.mess = "Data has been saved successfully.";
                model.key  = cust.PKey;
            }
            catch (Exception ex)
            {
                model.flag = 0;
                model.mess = ex.Message.ToString();
            }
            return(model);
        }
Beispiel #4
0
        public ActionResult NotesandActivity(Guid id)
        {
            if (GlobalClass.SystemSession)
            {
                ViewBag.mess = " ";

                RCSMessegeClass model = new RCSMessegeClass();
                model         = manage.LoadCustomerMessegingData(id);
                ViewBag.mess  = "MY RCS JOB " + model.Job.JobName + " - Activities.";
                ViewBag.title = "Activities Related to JOB - " + model.Job.JobName;
                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }
Beispiel #5
0
        public ActionResult NotesandActivity(RCSMessegeClass model, string save, string savenEmail)
        {
            if (GlobalClass.SystemSession)
            {
                ViewBag.mess  = "MY RCS JOB " + model.Job.JobName + " - Activities.";
                ViewBag.title = "Activities Related to JOB - " + model.Job.JobName;

                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(save))
                    {
                        if (model.mainObj.PKey == null || model.mainObj.PKey == Guid.Empty)
                        {
                            DataReturn data = manage.SaveCustomermessegingData(model);
                            ViewBag.mess = data.mess;
                            model        = manage.LoadCustomerMessegingData((Guid)model.mainObj.JobKey);
                        }
                        else
                        {
                            DataReturn data = manage.UpdateCustomermessegingData(model);
                            ViewBag.mess = data.mess;
                            model        = manage.LoadCustomerMessegingData((Guid)model.mainObj.JobKey);
                        }
                    }
                    if (!string.IsNullOrEmpty(savenEmail))
                    {
                        //DataReturn data = manage.SaveCustomermessegingData(model);
                        //CustomerMesseging lastObj = db.CustomerMesseging.Find(data.key);
                        //bool f = Mail.SendEmailToCustomerForJobUpdate(lastObj);
                        //ViewBag.mess = data.mess;
                        //model = manage.LoadCustomerMessegingData((Guid)model.mainObj.JobKey);
                    }
                }

                model = manage.LoadCustomerMessegingData((Guid)model.mainObj.JobKey);
                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }