예제 #1
0
        public async Task <JsonResult> MSInsert()
        {
            var id   = Guid.Parse(Request.Form["id"]);
            var uid  = Guid.Parse(Request.Form["uid"]);
            var name = Request.Form["name"];
            var aid  = Guid.Parse(Request.Form["aid"]);
            var scid = Guid.Parse(Request.Form["scid"]);
            var sbid = Guid.Parse(Request.Form["sbid"]);
            var slid = Guid.Parse(Request.Form["slid"]);
            var dtid = Guid.Parse(Request.Form["dtid"]);

            try {
                if (MyStoreService.IsStoreNameAllowUse(name))
                {
                    //remove dtid
                    DateTimeStorageService.RemoveAdmin(dtid);
                    return(Failed(MessageUtilityService.InUse("Store Name")));
                }
                if (MyStoreService.Insert(id, uid, name, aid, scid, sbid, slid, false, dtid))
                {
                    return(Success(id.ToString()));
                }
                //removing datetimeID
                DateTimeStorageService.RemoveAdmin(dtid);
                return(Failed(MessageUtilityService.FailedInsert("MyStore")));
            } catch {
                DateTimeStorageService.RemoveAdmin(dtid);
                return(Failed(MessageUtilityService.ServerError()));
            }
        }
        public async Task <JsonResult> UInsert()
        {
            var dtid = Guid.Parse(Request.Form["dtid"]);

            try {
                var id             = Guid.Parse(Request.Form["id"]);
                var fname          = Request.Form["fname"];
                var lname          = Request.Form["lname"];
                var mname          = Request.Form["mname"];
                var add            = Request.Form["add"];
                var email          = Request.Form["email"];
                var pass           = Request.Form["pass"];
                var repass         = Request.Form["rpass"];
                var cnum           = Request.Form["cnum"];
                var isAllow        = Boolean.Parse(Request.Form["ia"]);
                var areg           = Guid.Parse(Request.Form["areg"]);
                var profID         = Guid.Parse(Request.Form["profid"]);
                var aid            = Guid.Parse(Request.Form["aid"]);
                var hashedPassword = UsersService.GenerateHashPassword(pass);
                if (ApplicationInformationService.GetByID(areg) == null)
                {
                    DateTimeStorageService.RemoveAdmin(dtid);
                    return(Failed("Please do not modify link to complete the signup process " + areg));
                }
                if (!pass.Equals(repass))
                {
                    DateTimeStorageService.RemoveAdmin(dtid);
                    return(Failed("Make sure password matches retype password"));
                }
                if (ValidateEmailAddress(email))
                {
                    if (ValidateContactNumber(cnum))
                    {
                        if (UsersService.Insert(id, fname, lname, mname, add, email, hashedPassword, cnum, isAllow, areg, profID, dtid))
                        {
                            InsertNewUserInformation(id, aid, Guid.Parse("7d789492-1c6c-4ea2-9e1e-893a68620d1e"));
                            return(Success(id.ToString()));
                        }
                    }
                    else
                    {
                        DateTimeStorageService.RemoveAdmin(dtid);
                        return(Failed(MessageUtilityService.InUse("Mobile Number")));
                    }
                }
                DateTimeStorageService.RemoveAdmin(dtid);
                return(Failed(MessageUtilityService.FailedInsert("Signup")));
            } catch {
                DateTimeStorageService.RemoveAdmin(dtid);
                return(Failed(MessageUtilityService.ServerError()));
            }
        }