示例#1
0
        public Labelitem addNewLabel(int adminId, string LabelName, string description)
        {
            Labelitem           _item   = new Labelitem();
            Global              _global = new Database.Global();
            CRMClassDataContext _idc    = new Database.CRMClassDataContext(_global.con);

            try
            {
                var list = _idc.tbllabels.Where(a => a.AdminId == adminId && a.Isactive == true && a.LableName == LabelName).ToList();
                if (list.Count() > 0)
                {
                    _item.Error = "Error : Label already exist with " + LabelName + " ,please choose any other name";
                }
                else
                {
                    var tbl = new tbllabel {
                        AdminId = adminId, CreatedDate = DateTime.Now, Description = description, Isactive = true, LableName = LabelName, TotalContacts = 0
                    };
                    _idc.tbllabels.InsertOnSubmit(tbl);
                    _idc.SubmitChanges();
                    _item.LabelId       = tbl.Id;
                    _item.Name          = tbl.LableName;
                    _item.description   = tbl.Description;
                    _item.Totalcontacts = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_item);
        }
示例#2
0
        public Labelitem getLablesByLabelid(int labelId)
        {
            Labelitem           _item   = new Labelitem();
            Global              _global = new Database.Global();
            CRMClassDataContext _idc    = new Database.CRMClassDataContext(_global.con);

            try
            {
                var list = _idc.tbllabels.Where(a => a.Id == labelId).ToList();
                foreach (var item in list)
                {
                    _item.LabelId       = item.Id;
                    _item.Name          = item.LableName;
                    _item.description   = item.Description;
                    _item.Active        = item.Isactive.Value;
                    _item.Totalcontacts = item.TotalContacts.HasValue ? item.TotalContacts.Value : 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_item);
        }
示例#3
0
        public LabelModel getAllLablesByAdminid(int adminId)
        {
            LabelModel          _profile  = new Models.LabelModel();
            List <Labelitem>    _listitem = new List <Labelitem>();
            Global              _global   = new Database.Global();
            CRMClassDataContext _idc      = new Database.CRMClassDataContext(_global.con);

            try
            {
                var list = _idc.tbllabels.Where(a => a.AdminId == adminId && a.Isactive == true).ToList();
                foreach (var item in list)
                {
                    Labelitem _item = new Labelitem();
                    _item.LabelId       = item.Id;
                    _item.Name          = item.LableName;
                    _item.description   = item.Description;
                    _item.Totalcontacts = item.TotalContacts.HasValue ? item.TotalContacts.Value : 0;
                    _listitem.Add(_item);
                }
                _profile._labelList = _listitem;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_profile);
        }
示例#4
0
        public ActionResult editlabels(Labelitem _model)
        {
            int             adminId = Convert.ToInt16(Session["AdminId"]);
            contactServices _ser    = new Database.contactServices();
            var             msg     = _ser.updateLabelById(_model.LabelId, _model.Active, adminId, _model.Name, _model.description);

            if (!string.IsNullOrEmpty(msg.Error))
            {
                _model.Error = msg.Error;
                return(View("editLabel", _model));
            }
            else
            {
                TempData["Error"] = _model.Name + " Updated Succesfully";
                return(RedirectToAction("Labellist"));
            }
        }
示例#5
0
        public Labelitem updateLabelById(int labelId, bool active, int adminId, string LabelName, string description)
        {
            Labelitem           _item   = new Labelitem();
            Global              _global = new Database.Global();
            CRMClassDataContext _idc    = new Database.CRMClassDataContext(_global.con);

            try
            {
                var list = _idc.tbllabels.Where(a => a.AdminId == adminId && a.Id != labelId && a.Isactive == true && a.LableName == LabelName).ToList();
                if (list.Count() > 0)
                {
                    _item.Error = "Error : Label already exist with " + LabelName + " ,please choose any other name";
                }
                else
                {
                    var item = _idc.tbllabels.Where(a => a.Id == labelId).FirstOrDefault();
                    item.Description = description;
                    item.LableName   = LabelName;
                    item.Isactive    = active;
                    item.AdminId     = adminId;
                    _idc.SubmitChanges();
                    _item.LabelId       = item.Id;
                    _item.Name          = item.LableName;
                    _item.description   = item.Description;
                    _item.Totalcontacts = item.TotalContacts.Value;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _idc.Dispose();
            }
            return(_item);
        }