예제 #1
0
        public ActionResult DeleteEmail(int Id)
        {
            int UserId = int.Parse(Session["UserID"].ToString());

            DSRCManagementSystem.EmailPurposeLog fed = new DSRCManagementSystem.EmailPurposeLog();

            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
            var ajenda = objdb.EmailPurposes.Where(x => x.EmailPurposeID == Id && x.IsActive == true).Select(o => o).FirstOrDefault();
            var log    = objdb.EmailPurposeLogs.Where(x => x.EmailPurposeID == ajenda.EmailPurposeID).FirstOrDefault();

            if (log != null)
            {
                log.IsActive         = false;
                log.UpdatedUserID    = UserId;
                log.Datetimestamp    = System.DateTime.Now;
                log.ParameterChanges = "IsActive";
                objdb.SaveChanges();
            }
            else
            {
                fed.Datetimestamp    = System.DateTime.Now;
                fed.EmailPurposeID   = ajenda.EmailPurposeID;
                fed.IsActive         = false;
                fed.ParameterChanges = "Isactive";
                fed.UpdatedUserID    = UserId;
                fed.Content          = "1";
                objdb.AddToEmailPurposeLogs(fed);
                objdb.SaveChanges();
            }
            ajenda.IsActive = false;
            objdb.SaveChanges();



            return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult AddNewEdit(Email objmail)
        {
            int UserId = int.Parse(Session["UserID"].ToString());

            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            DSRCManagementSystem.EmailPurposeLog obj = new DSRCManagementSystem.EmailPurposeLog();

            var fed = db.EmailPurposes.Where(x => x.EmailPurposeName == objmail.Purpose).Select(o => o).FirstOrDefault();


            if (fed.To != objmail.To && fed.CC != objmail.CC && fed.BCC != objmail.BCC)
            {
                obj.EmailPurposeID   = fed.EmailPurposeID;
                obj.Datetimestamp    = System.DateTime.Now;
                obj.IsActive         = true;
                obj.Content          = fed.To + "/" + fed.CC + "/" + fed.BCC;
                obj.ParameterChanges = "TO/CC/BCC";
                obj.UpdatedUserID    = UserId;
                db.AddToEmailPurposeLogs(obj);
                db.SaveChanges();
            }

            if (fed.To != objmail.To && fed.CC == objmail.CC && fed.BCC == objmail.BCC)
            {
                obj.EmailPurposeID   = fed.EmailPurposeID;
                obj.Datetimestamp    = System.DateTime.Now;
                obj.Content          = fed.To;
                obj.IsActive         = true;
                obj.ParameterChanges = "TO";
                obj.UpdatedUserID    = UserId;
                db.AddToEmailPurposeLogs(obj);
                db.SaveChanges();
            }

            else if (fed.CC != objmail.CC && fed.To == objmail.To && fed.BCC == objmail.BCC)
            {
                obj.EmailPurposeID   = fed.EmailPurposeID;
                obj.Datetimestamp    = System.DateTime.Now;
                obj.IsActive         = true;
                obj.Content          = fed.CC;
                obj.ParameterChanges = "CC";
                obj.UpdatedUserID    = UserId;
                db.AddToEmailPurposeLogs(obj);
                db.SaveChanges();
            }

            if (fed.BCC != null)
            {
                if (fed.BCC != objmail.BCC && fed.CC == objmail.CC && fed.To == objmail.To)
                {
                    obj.EmailPurposeID   = fed.EmailPurposeID;
                    obj.Datetimestamp    = System.DateTime.Now;
                    obj.IsActive         = true;
                    obj.Content          = fed.BCC;
                    obj.ParameterChanges = "BCC";
                    obj.UpdatedUserID    = UserId;
                    db.AddToEmailPurposeLogs(obj);
                    db.SaveChanges();
                }
            }

            else if (fed.Subject != objmail.Subject && fed.CC == objmail.CC && fed.BCC == objmail.BCC)
            {
                obj.EmailPurposeID   = fed.EmailPurposeID;
                obj.ParameterChanges = "Subject";
                obj.Content          = "";
                obj.UpdatedUserID    = UserId;
                obj.Datetimestamp    = System.DateTime.Now;
                obj.IsActive         = true;
                db.AddToEmailPurposeLogs(obj);
                db.SaveChanges();
            }
            fed.EmailPurposeName = objmail.Purpose;
            fed.To      = objmail.To != null ? objmail.To : "";
            fed.CC      = objmail.CC != null ? objmail.CC : "";
            fed.BCC     = objmail.BCC != null ? objmail.BCC : "";
            fed.Subject = objmail.Subject;
            // fed.EmailTemplateID = objmail.Template;
            db.SaveChanges();
            return(Json(new { Result = "Success", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
        }