Esempio n. 1
0
        public CrmResponse DeleteJBI(int idJBI)
        {
            CrmResponse response = new CrmResponse();

            try
            {
                JBI one = _context.JBIs.Where((x) => x.Moneln == idJBI).FirstOrDefault();
                if (one != null)
                {
                    _context.JBIs.Remove(one);
                    _context.SaveChanges();
                    response.rc    = 0;
                    response.title = "Delete one JBI success";
                }
                else
                {
                    response.rc    = 1;
                    response.title = "Id is not found";
                }
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                response.desc = ex.Message;
            }

            return(response);
        }
Esempio n. 2
0
 public void SetButtonClicked(int id, int button)
 {
     try
     {
         EmailsSend editRow = _context.EmailsSends.Where(x => x.LineId == id).FirstOrDefault();
         if (editRow != null)
         {
             editRow.IsOpen        = true;
             editRow.ClickedAnswer = button;
             _context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 3
0
        public CrmResponse InsertNewActivity(ENTITIES.Activity activity)
        {
            CrmResponse response = new CrmResponse();

            try
            {
                Activity       newActivity = new Activity();
                Type           myType      = newActivity.GetType();
                PropertyInfo[] props       = myType.GetProperties();
                foreach (PropertyInfo prop in props)
                {
                    object temp = activity.GetType().GetProperty(prop.Name);
                    if (!(temp is null))
                    {
                        object activityValue = activity.GetType().GetProperty(prop.Name).GetValue(activity);
                        newActivity.GetType().GetProperty(prop.Name).SetValue(newActivity, activityValue);
                    }
                }

                //buttons
                newActivity.Button1    = activity.Buttons[0];
                newActivity.Button2    = activity.Buttons[1];
                newActivity.Button3    = activity.Buttons[2];
                newActivity.InsertDate = DateTime.Now;

                Activity act = _context.Activities.Add(newActivity);
                _context.SaveChanges();
                int activityId = act.ActivityId;

                //textBoxes
                List <TextBox> textBoxes = new List <TextBox>();
                foreach (var item in activity.TextBoxList)
                {
                    TextBox textBox = new TextBox
                    {
                        ActivityId = activityId,
                        Bold       = item.Bold,
                        Color      = item.Color,
                        FontSize   = item.FontSize,
                        Text       = item.Text,
                        TextBoxId  = item.BoxId
                    };
                    textBoxes.Add(textBox);
                }
                _context.TextBoxes.AddRange(textBoxes);
                _context.SaveChanges();

                //JBI
                List <ActivityJBI> JBIs = new List <ActivityJBI>();
                foreach (var item in activity.JBIlist)
                {
                    ActivityJBI jbi = new ActivityJBI
                    {
                        ActivityId = activityId,
                        JBIId      = item.Moneln
                    };
                    JBIs.Add(jbi);
                }
                _context.ActivityJBIs.AddRange(JBIs);
                _context.SaveChanges();
                response.rc = activityId;
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                response.desc = ex.Message;
                response.rc   = -1;
            }

            return(response);
        }