public ActionResult Index()
 {
     if (SynergySecurity.IsAdmin())
     {
         return(RedirectToAction("Index", "Administration"));
     }
     return(View());
 }
Exemple #2
0
 public ActionResult AddContact(CreateContactRequest model)
 {
     model.UserId  = SynergySecurity.GetCurrentUser();
     model.Api     = ApiTypes.AgileCrm;
     model.Request = "Create New Contact";
     contactApi.AddContact(model);
     return(RedirectToAction("Contacts"));
 }
Exemple #3
0
 public ActionResult Edit(int id, UserModel model)
 {
     ModelState.Remove("Id");
     if (ModelState.IsValid)
     {
         SynergySecurity.Update(id, model.Age, model.Email, model.FirstName, model.LastName);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemple #4
0
        public ActionResult ContactDelete(long id, FormCollection collection)
        {
            var request = new DeleteContactRequest(SynergySecurity.GetCurrentUser());

            request.Id = id;
            var RecordId = SynergySecurity.ToLog <DeleteContactRequest>(request);
            DeleteContactResponse response = contactApi.DeleteContact(request);

            SynergySecurity.ToUpdateLog <DeleteContactResponse>(response, RecordId);
            return(RedirectToAction("Contacts"));
        }
Exemple #5
0
        public ActionResult EditContact(UpdateContactRequest model)
        {
            model.UserId  = SynergySecurity.GetCurrentUser();
            model.Api     = ApiTypes.AgileCrm;
            model.Request = "Update Contact details";
            var RecordId = SynergySecurity.ToLog <UpdateContactRequest>(model);
            UpdateContactResponse response = contactApi.UpdateContactProperty(model);

            SynergySecurity.ToUpdateLog <UpdateContactResponse>(response, RecordId);
            return(RedirectToAction("Contacts"));
        }
Exemple #6
0
        public ActionResult Contacts()
        {
            var request  = new GetContactsRequest(SynergySecurity.GetCurrentUser());
            var RecordId = SynergySecurity.ToLog <GetContactsRequest>(request);
            var contacts = contactApi.GetContacts(request);

            SynergySecurity.ToUpdateLog <GetContactsResponse>(contacts, RecordId);
            var model = ToUpdateContactRequestList(contacts);

            return(View("ContactList", model));
        }
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         if (SynergySecurity.Login(model.UserName, model.Password))
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     ModelState.AddModelError("", "Username or Password provide incorrect");
     return(View(model));
 }
Exemple #8
0
 public ActionResult Create(UserModel model)
 {
     ModelState.Remove("Id");
     if (ModelState.IsValid)
     {
         Synergy_User user = new Synergy_User()
         {
             Age       = model.Age,
             Email     = model.Email,
             FirstName = model.FirstName,
             LastName  = model.LastName,
             IsActive  = true,
             UserRole  = "user",
         };
         SynergySecurity.Create(user, model.UserName);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemple #9
0
        public ActionResult ContactDelete(long id)
        {
            UpdateContactRequest request = null;
            var getRequest = new GetContactRequest(SynergySecurity.GetCurrentUser());

            getRequest.Id = id;
            var RecordId = SynergySecurity.ToLog <GetContactRequest>(getRequest);
            var model    = contactApi.GetContact(getRequest);

            SynergySecurity.ToUpdateLog <GetContactResponse>(model, RecordId);
            if (model != null)
            {
                request = new UpdateContactRequest()
                {
                    Id       = model.Contact.id,
                    Property = ToConvertContactProperty(model.Contact)
                };
            }
            return(View(request ?? new UpdateContactRequest()));
        }
Exemple #10
0
        public void AgileCrmInit(ref ContactApi contactApi, ref DealApi dealApi)
        {
            using (var ctx = new SynergyDbContext())
            {
                var userId = SynergySecurity.GetCurrentUser();

                var apiConfiguration = ctx.Synergy_ApiConfigurations.
                                       Where(x => x.UserId == userId && x.IsActive).FirstOrDefault();
                if (apiConfiguration != null)
                {
                    contactApi = new ContactApi(agileKey: apiConfiguration.Key, agileEmail: apiConfiguration.Email, agileUrl: apiConfiguration.Url);
                    dealApi    = new DealApi(agileKey: apiConfiguration.Key, agileEmail: apiConfiguration.Email, agileUrl: apiConfiguration.Url);
                }
                else
                {
                    contactApi = new ContactApi();
                    dealApi    = new DealApi();
                }
            }
        }
Exemple #11
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     SynergySecurity.Delete(id);
     return(RedirectToAction("Index"));
 }
 public ActionResult Logoff()
 {
     SynergySecurity.Logoff();
     return(RedirectToAction("Index", "Home"));
 }