Exemple #1
0
        /// <summary>
        /// Author:Gavin
        /// Create Date:2017-03-14
        /// 添加服务单位企业信息
        /// </summary>
        /// <param name="serverCompany">服务单位实体</param>
        /// <returns></returns>
        public ActionResult ServiceCompany()
        {
            try
            {
                ServiceCompany serverCompany = JsonConvert.DeserializeObject <ServiceCompany>(Request.Form["servicecompany"].ToString());

                string fileName = string.Empty;
                HttpFileCollectionBase uploadFile = Request.Files;
                if (uploadFile.Count > 0)
                {
                    HttpPostedFileBase file = uploadFile[0];
                    string             path = ConfigurationManager.AppSettings["repairImgPath"].ToString() + "/" + PhotoType.Server.ToString() + "/";

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    fileName = Guid.NewGuid().ToString("N") + "." + file.ContentType.ToString().Split('/')[1];
                    file.SaveAs(path + "/" + fileName);
                }

                serverCompany.ImgUrl = !string.IsNullOrEmpty(fileName) ? PhotoType.Server.ToString() + "/" + fileName : "";
                cService.AddServiceCompanyInfo(serverCompany, new Picture {
                    Type = PhotoType.Server, Url = serverCompany.ImgUrl
                }, ApiUser.Current);
                return(Json(new { status = 0 }));
            }
            catch (DataExistException e)
            {
                return(Json(new { error = e.Message }));
            }
        }
Exemple #2
0
        public ActionResult Registers(ServiceCompany serverCompany)
        {
            try
            {
                if (CurrentUser.ServiceCompany == null || CurrentUser.ServiceCompany.State == CompanyState.Locked)
                {
                    HttpFileCollectionBase uploadFile = Request.Files;
                    List <Picture>         pInfo      = new List <Picture>();
                    if (uploadFile.Count > 0)
                    {
                        for (int i = 0; i < uploadFile.Count; i++)
                        {
                            HttpPostedFileBase file = uploadFile[i];
                            string             path = ConfigurationManager.AppSettings["repairImgPath"].ToString() + "/" + PhotoType.Server.ToString() + "/";

                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            string fileName = Guid.NewGuid().ToString("N") + "." + file.ContentType.ToString().Split('/')[1];
                            file.SaveAs(path + "/" + fileName);

                            pInfo.Add(new Picture
                            {
                                Type       = PhotoType.Server,
                                Url        = PhotoType.Server.ToString() + "/" + fileName,
                                CreateTime = DateTime.Now
                            });
                        }
                    }
                    cService.AddServiceCompanyInfo(serverCompany, CurrentUser.User);
                    CurrentUser.User = new MbContext().User.FirstOrDefault(t => t.Account == CurrentUser.User.Phone);

                    //上传图片
                    if (pInfo.Count != 0)
                    {
                        using (var db = new LZY.BX.Service.Mb.MbContext())
                        {
                            foreach (Picture item in pInfo)
                            {
                                item.OuterId    = CurrentUser.User.ServiceCompanyId;
                                item.CreateTime = DateTime.Now;
                                db.Picture.Add(item);
                            }
                            db.SaveChanges();
                        }
                    }
                    AuthMng.Instance.ResetUserCookie(HttpContext, new UserCookie(
                                                         new AuthUser
                    {
                        User           = CurrentUser.User,
                        UseCompany     = CurrentUser.UseCompany,
                        ServiceCompany = cService.GetServiceInfo(CurrentUser.User)
                    }));
                    return(ResultSuccess("提交成功.请稍后留意审核状态", Url.Action("Order", "Order")));
                }
                else
                {
                    return(ResultError("重复申请,您有一个单位等待审核中."));
                }
            }
            catch (DataExistException ex)
            {
                return(ResultError(ex.Message));
            }
        }